Date: Sat, 20 Oct 2018 19:42:39 +0000 (UTC) From: Conrad Meyer <cem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339478 - head/sys/kern Message-ID: <201810201942.w9KJgdUk082141@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201810201942.w9KJgdUk082141>