diff mbox series

[v1] fs: proc: Fix error checking for d_hash_and_lookup()

Message ID 20240826090802.2358591-1-yanzhen@vivo.com (mailing list archive)
State New
Headers show
Series [v1] fs: proc: Fix error checking for d_hash_and_lookup() | expand

Commit Message

Yan Zhen Aug. 26, 2024, 9:08 a.m. UTC
The d_hash_and_lookup() function returns either an error pointer or NULL.

It might be more appropriate to check error using IS_ERR_OR_NULL().

Signed-off-by: Yan Zhen <yanzhen@vivo.com>
---
 fs/proc/base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christian Brauner Aug. 26, 2024, 10:39 a.m. UTC | #1
On Mon, Aug 26, 2024 at 05:08:02PM GMT, Yan Zhen wrote:
> The d_hash_and_lookup() function returns either an error pointer or NULL.
> 
> It might be more appropriate to check error using IS_ERR_OR_NULL().
> 
> Signed-off-by: Yan Zhen <yanzhen@vivo.com>
> ---

I distinctly remember having NAKed a patch like this either earlier this
or last year. Procfs doesn't have a custom d_hash() function so
d_hash_and_lookup() will never return an error pointer afaict.
Al Viro Aug. 26, 2024, 1:49 p.m. UTC | #2
On Mon, Aug 26, 2024 at 05:08:02PM +0800, Yan Zhen wrote:
> The d_hash_and_lookup() function returns either an error pointer or NULL.
> 
> It might be more appropriate to check error using IS_ERR_OR_NULL().

Not for procfs it doesn't.  Please, don't use that shite.
diff mbox series

Patch

diff --git a/fs/proc/base.c b/fs/proc/base.c
index f83d41bf155d..e08b36dd4766 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2123,7 +2123,7 @@  bool proc_fill_cache(struct file *file, struct dir_context *ctx,
 	ino_t ino = 1;
 
 	child = d_hash_and_lookup(dir, &qname);
-	if (!child) {
+	if (IS_ERR_OR_NULL(child)) {
 		DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
 		child = d_alloc_parallel(dir, &qname, &wq);
 		if (IS_ERR(child))