lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240820012718.4121485-1-lizetao1@huawei.com>
Date: Tue, 20 Aug 2024 09:27:17 +0800
From: Li Zetao <lizetao1@...wei.com>
To: <kent.overstreet@...ux.dev>
CC: <lizetao1@...wei.com>, <linux-bcachefs@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>
Subject: [PATCH -next 1/2] bcachefs: Remove redundant checks

Since the kthread_create() and strndup_user() do not return a
null pointer, so it is enough to use IS_ERR instead of PTR_ERR_OR_ZERO
to check the return value. Moreover using PTR_ERR_OR_ZERO will do two
checks, while IS_ERR only does one.

No functional change intended.

Signed-off-by: Li Zetao <lizetao1@...wei.com>
---
 fs/bcachefs/chardev.c          | 10 ++++------
 fs/bcachefs/thread_with_file.c |  5 ++---
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c
index ef1f74866e23..c315421bee85 100644
--- a/fs/bcachefs/chardev.c
+++ b/fs/bcachefs/chardev.c
@@ -316,9 +316,8 @@ static long bch2_ioctl_disk_add(struct bch_fs *c, struct bch_ioctl_disk arg)
 		return -EINVAL;
 
 	path = strndup_user((const char __user *)(unsigned long) arg.dev, PATH_MAX);
-	ret = PTR_ERR_OR_ZERO(path);
-	if (ret)
-		return ret;
+	if (IS_ERR(path))
+		return PTR_ERR(path);
 
 	ret = bch2_dev_add(c, path);
 	if (!IS_ERR(path))
@@ -360,9 +359,8 @@ static long bch2_ioctl_disk_online(struct bch_fs *c, struct bch_ioctl_disk arg)
 		return -EINVAL;
 
 	path = strndup_user((const char __user *)(unsigned long) arg.dev, PATH_MAX);
-	ret = PTR_ERR_OR_ZERO(path);
-	if (ret)
-		return ret;
+	if (IS_ERR(path))
+		return PTR_ERR(path);
 
 	ret = bch2_dev_online(c, path);
 	kfree(path);
diff --git a/fs/bcachefs/thread_with_file.c b/fs/bcachefs/thread_with_file.c
index 0807ce9b171a..e8ba0d0cc0df 100644
--- a/fs/bcachefs/thread_with_file.c
+++ b/fs/bcachefs/thread_with_file.c
@@ -39,9 +39,8 @@ int bch2_run_thread_with_file(struct thread_with_file *thr,
 
 	thr->ret = 0;
 	thr->task = kthread_create(fn, thr, "%s", name);
-	ret = PTR_ERR_OR_ZERO(thr->task);
-	if (ret)
-		return ret;
+	if (IS_ERR(thr->task))
+		return PTR_ERR(thr->task);
 
 	ret = get_unused_fd_flags(fd_flags);
 	if (ret < 0)
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ