devsd: fix possible sdbio() race with inquiry data changing (due to ahci hotplug)
the unit inquiry data might change in case the drive got pulled with ahci. so keep track if we locked the ctl in a local stack variable instead of relying on that the inquiry data stays the same.
This commit is contained in:
parent
7ceff03db3
commit
4a4c8218ee
|
@ -770,7 +770,7 @@ sdclose(Chan* c)
|
|||
static long
|
||||
sdbio(Chan* c, int write, char* a, long len, uvlong off)
|
||||
{
|
||||
int nchange, hard, allocd;
|
||||
int nchange, hard, allocd, locked;
|
||||
long l;
|
||||
uchar *b;
|
||||
SDpart *pp;
|
||||
|
@ -832,7 +832,8 @@ sdbio(Chan* c, int write, char* a, long len, uvlong off)
|
|||
poperror();
|
||||
return 0;
|
||||
}
|
||||
if(!(unit->inquiry[1] & 0x80)){
|
||||
locked = (unit->inquiry[1] & 0x80) != 0;
|
||||
if(!locked){
|
||||
qunlock(&unit->ctl);
|
||||
poperror();
|
||||
}
|
||||
|
@ -854,7 +855,7 @@ sdbio(Chan* c, int write, char* a, long len, uvlong off)
|
|||
if(waserror()){
|
||||
if(allocd)
|
||||
sdfree(b);
|
||||
if(!(unit->inquiry[1] & 0x80))
|
||||
if(!locked)
|
||||
decref(&sdev->r); /* gadverdamme! */
|
||||
nexterror();
|
||||
}
|
||||
|
@ -896,7 +897,7 @@ sdbio(Chan* c, int write, char* a, long len, uvlong off)
|
|||
sdfree(b);
|
||||
poperror();
|
||||
|
||||
if(unit->inquiry[1] & 0x80){
|
||||
if(locked){
|
||||
qunlock(&unit->ctl);
|
||||
poperror();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue