aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2021-05-03 16:43:29 +0000
committerMark Johnston <markj@FreeBSD.org>2021-05-03 17:24:30 +0000
commit243b324f96686642177c8479c03288e2a6f68b50 (patch)
tree22dc1ef6daa961d97b22438a6c7a2aec6628c30a
parent2b2d77e7204d2264dbe0338f4400f14702a2c582 (diff)
downloadsrc-243b324f96686642177c8479c03288e2a6f68b50.tar.gz
src-243b324f96686642177c8479c03288e2a6f68b50.zip
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
-rw-r--r--sys/fs/devfs/devfs_vnops.c3
1 files changed, 1 insertions, 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);