HomeFreeBSD

mmc_sim: fix setting of the mutex name

Description

mmc_sim: fix setting of the mutex name

To quote the manual:
The pointer passed in as name and type is saved rather than the data
it points to. The data pointed to must remain stable until the mutex
is destroyed.

It seems that the type is actually copied, but the name is stored as
a pointer indeed.
mmc_cam_sim_alloc used a name stored on stack.
So, a corrupt mutex name would be reported.
For example:

lock order reversal: (sleepable after non-sleepable)
1st 0xd7285b20 <8A><C0><C0>P@<C1><D0>P@<C1>^D^A (aw_mmc_sim, sleep mutex) @ sys/cam/cam_xpt.c:2804

This change moves the name to struct mmc_sim.
Also, that name is used as the sim name as well.
Unused mtx_name variable is removed too.
The name buffer is reduced to 16 characters.

(cherry picked from commit 18679ab1c06575517df9df2509564dbf038d4720)
(cherry picked from commit 8eca341d9bb678f08065edd8f24c2ab32dcf8e56)

Details

Provenance
avgAuthored on Dec 15 2021, 11:37 AM
Parents
rG6cccfeaafc29: nfscl: Fix must_commit/writeverf handling for Direct I/O
Branches
Unknown
Tags
Unknown