summaryrefslogtreecommitdiff
path: root/fs/bcachefs/chardev.c
diff options
context:
space:
mode:
authorDan Robertson <dan@dlrobertson.com>2021-05-13 03:54:37 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:03 +0300
commit2b25de552f8a8d9cae5b54c83137c67e03ee1957 (patch)
treecaf0f48a106483a71fa82d8810e23a967d3f6860 /fs/bcachefs/chardev.c
parentec4ab9d2fc08132113dc5d45ac68af2158377122 (diff)
downloadlinux-2b25de552f8a8d9cae5b54c83137c67e03ee1957.tar.xz
bcachefs: Fix null deref in bch2_ioctl_read_super
Do not attempt to cleanup the returned value of bch2_device_lookup if the returned value was an error pointer. We currently check to see if the returned value is null and run the cleanup otherwise. As a result, we attempt to run the cleanup on a error pointer. Signed-off-by: Dan Robertson <dan@dlrobertson.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/chardev.c')
-rw-r--r--fs/bcachefs/chardev.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c
index 34085e32a159..b0cbbb70161d 100644
--- a/fs/bcachefs/chardev.c
+++ b/fs/bcachefs/chardev.c
@@ -523,7 +523,7 @@ static long bch2_ioctl_read_super(struct bch_fs *c,
ret = copy_to_user((void __user *)(unsigned long)arg.sb,
sb, vstruct_bytes(sb));
err:
- if (ca)
+ if (!IS_ERR_OR_NULL(ca))
percpu_ref_put(&ca->ref);
mutex_unlock(&c->sb_lock);
return ret;