linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] fs: proc: Fix error checking for d_hash_and_lookup()
@ 2024-08-26  9:08 Yan Zhen
  2024-08-26 10:39 ` Christian Brauner
  2024-08-26 13:49 ` Al Viro
  0 siblings, 2 replies; 3+ messages in thread
From: Yan Zhen @ 2024-08-26  9:08 UTC (permalink / raw)
  To: viro, brauner; +Cc: jack, linux-fsdevel, opensource.kernel, Yan Zhen

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(-)

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))
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] fs: proc: Fix error checking for d_hash_and_lookup()
  2024-08-26  9:08 [PATCH v1] fs: proc: Fix error checking for d_hash_and_lookup() Yan Zhen
@ 2024-08-26 10:39 ` Christian Brauner
  2024-08-26 13:49 ` Al Viro
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2024-08-26 10:39 UTC (permalink / raw)
  To: Yan Zhen; +Cc: viro, jack, linux-fsdevel, opensource.kernel

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] fs: proc: Fix error checking for d_hash_and_lookup()
  2024-08-26  9:08 [PATCH v1] fs: proc: Fix error checking for d_hash_and_lookup() Yan Zhen
  2024-08-26 10:39 ` Christian Brauner
@ 2024-08-26 13:49 ` Al Viro
  1 sibling, 0 replies; 3+ messages in thread
From: Al Viro @ 2024-08-26 13:49 UTC (permalink / raw)
  To: Yan Zhen; +Cc: brauner, jack, linux-fsdevel, opensource.kernel

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-26 13:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-26  9:08 [PATCH v1] fs: proc: Fix error checking for d_hash_and_lookup() Yan Zhen
2024-08-26 10:39 ` Christian Brauner
2024-08-26 13:49 ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).