dev_refthread: Do not initialize *ref when reference was not acquired
Like the companion API devvn_refthread, leave *ref uninitialized when a reference was not acquired. Initializing to 1 provides a vaguely correct-looking but bogus value for broken callers to (mistakenly) pass to dev_relthread() when refthread fails. Make it even more clear to consumers that dev_relthread is only valid when dev_refthread succeeds. Reviewed by: kib, markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D16885
This commit is contained in:
parent
6675ac3ac4
commit
91754b1945
@ -202,7 +202,8 @@ dev_refthread(struct cdev *dev, int *ref)
|
||||
csw = NULL;
|
||||
}
|
||||
dev_unlock();
|
||||
*ref = 1;
|
||||
if (csw != NULL)
|
||||
*ref = 1;
|
||||
return (csw);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user