public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Deepak R Varma <drv@mailo.com>
To: Bob Peterson <rpeterso@redhat.com>,
	Andreas Gruenbacher <agruenba@redhat.com>,
	gfs2@lists.linux.dev, linux-kernel@vger.kernel.org
Cc: linux-kernel-mentees@lists.linuxfoundation.org,
	Dan Carpenter <error27@gmail.com>, Deepak R Varma <drv@mailo.com>
Subject: [PATCH] gfs2: fix 'passing zero to ERR_PTR()' warning
Date: Thu, 28 Sep 2023 23:37:42 +0530	[thread overview]
Message-ID: <ZRXA7n0wD83zhPxC@runicha.com> (raw)

Resolve the following Smatch static checker warning:
	fs/gfs2/acl.c:54 __gfs2_get_acl() warn: passing zero to 'ERR_PTR'

by returning NULL when an extended attribute length is zero, instead of
passing on zero to the ERR_PTR().

Signed-off-by: Deepak R Varma <drv@mailo.com>
---
Please note: Patch is build tested only.


 fs/gfs2/acl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
index 443640e6fb9c..818d67f10dcf 100644
--- a/fs/gfs2/acl.c
+++ b/fs/gfs2/acl.c
@@ -50,8 +50,11 @@ static struct posix_acl *__gfs2_get_acl(struct inode *inode, int type)

 	name = gfs2_acl_name(type);
 	len = gfs2_xattr_acl_get(ip, name, &data);
-	if (len <= 0)
+	if (len == 0)
+		return NULL;
+	if (len < 0)
 		return ERR_PTR(len);
+
 	acl = posix_acl_from_xattr(&init_user_ns, data, len);
 	kfree(data);
 	return acl;
--
2.39.2




             reply	other threads:[~2023-09-28 18:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28 18:07 Deepak R Varma [this message]
2023-09-29  7:06 ` [PATCH] gfs2: fix 'passing zero to ERR_PTR()' warning Dan Carpenter
2023-09-29  7:39   ` drv

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZRXA7n0wD83zhPxC@runicha.com \
    --to=drv@mailo.com \
    --cc=agruenba@redhat.com \
    --cc=error27@gmail.com \
    --cc=gfs2@lists.linux.dev \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rpeterso@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox