Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 May 2021 17:55:41 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 243b324f9668 - main - devfs: Avoid comparison with an uninitialized var in devfs_fp_check()
Message-ID:  <202105031755.143HtfUP046841@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=243b324f96686642177c8479c03288e2a6f68b50

commit 243b324f96686642177c8479c03288e2a6f68b50
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-05-03 16:43:29 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-05-03 17:24:30 +0000

    devfs: Avoid comparison with an uninitialized var in devfs_fp_check()
    
    devvn_refthread() will initialize *devp only if it succeeds, so check for
    success before comparing with fp->f_data.  Other devvn_refthread()
    callers are careful to do this.
    
    Reported by:    KMSAN
    Reviewed by:    kib
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D30068
---
 sys/fs/devfs/devfs_vnops.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c
index 043cee74fde2..40b80596523d 100644
--- a/sys/fs/devfs/devfs_vnops.c
+++ b/sys/fs/devfs/devfs_vnops.c
@@ -120,9 +120,8 @@ static int
 devfs_fp_check(struct file *fp, struct cdev **devp, struct cdevsw **dswp,
     int *ref)
 {
-
 	*dswp = devvn_refthread(fp->f_vnode, devp, ref);
-	if (*devp != fp->f_data) {
+	if (*dswp == NULL || *devp != fp->f_data) {
 		if (*dswp != NULL)
 			dev_relthread(*devp, *ref);
 		return (ENXIO);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105031755.143HtfUP046841>