svn commit: r339478 - head/sys/kern
Conrad Meyer
cem at FreeBSD.org
Sat Oct 20 19:42:39 UTC 2018
Author: cem
Date: Sat Oct 20 19:42:38 2018
New Revision: 339478
URL: https://svnweb.freebsd.org/changeset/base/339478
Log:
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
Modified:
head/sys/kern/kern_conf.c
Modified: head/sys/kern/kern_conf.c
==============================================================================
--- head/sys/kern/kern_conf.c Sat Oct 20 19:18:30 2018 (r339477)
+++ head/sys/kern/kern_conf.c Sat Oct 20 19:42:38 2018 (r339478)
@@ -202,7 +202,8 @@ dev_refthread(struct cdev *dev, int *ref)
csw = NULL;
}
dev_unlock();
- *ref = 1;
+ if (csw != NULL)
+ *ref = 1;
return (csw);
}
More information about the svn-src-all
mailing list