cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xattr: fix uninitialized out-param
@ 2020-04-09  6:27 Daniel Xu
  2020-04-09 19:34 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Xu @ 2020-04-09  6:27 UTC (permalink / raw)
  To: tj, viro
  Cc: Daniel Xu, cgroups, linux-fsdevel, linux-kernel, kernel-janitors,
	Dan Carpenter

`removed_sized` isn't correctly initialized (as the doc comment
suggests) on memory allocation failures. Fix by moving initialization up
a bit.

Fixes: 0c47383ba3bd ("kernfs: Add option to enable user xattrs")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
---

I'm sending this through the cgroup tree b/c the original patchset went
through it. I don't believe the patchset has made its way into mainline
yet. Hopefully this is ok.

 fs/xattr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/xattr.c b/fs/xattr.c
index e13265e65871..91608d9bfc6a 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -876,6 +876,9 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
 	struct simple_xattr *new_xattr = NULL;
 	int err = 0;
 
+	if (removed_size)
+		*removed_size = -1;
+
 	/* value == NULL means remove */
 	if (value) {
 		new_xattr = simple_xattr_alloc(value, size);
@@ -914,9 +917,6 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
 		list_add(&new_xattr->list, &xattrs->head);
 		xattr = NULL;
 	}
-
-	if (removed_size)
-		*removed_size = -1;
 out:
 	spin_unlock(&xattrs->lock);
 	if (xattr) {
-- 
2.26.0


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

* Re: [PATCH] xattr: fix uninitialized out-param
  2020-04-09  6:27 [PATCH] xattr: fix uninitialized out-param Daniel Xu
@ 2020-04-09 19:34 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2020-04-09 19:34 UTC (permalink / raw)
  To: Daniel Xu
  Cc: viro, cgroups, linux-fsdevel, linux-kernel, kernel-janitors,
	Dan Carpenter

On Wed, Apr 08, 2020 at 11:27:29PM -0700, Daniel Xu wrote:
> `removed_sized` isn't correctly initialized (as the doc comment
> suggests) on memory allocation failures. Fix by moving initialization up
> a bit.
> 
> Fixes: 0c47383ba3bd ("kernfs: Add option to enable user xattrs")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>

Appiled to cgroup/for-5.7-fixes.

Thanks.

-- 
tejun

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

end of thread, other threads:[~2020-04-09 19:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-09  6:27 [PATCH] xattr: fix uninitialized out-param Daniel Xu
2020-04-09 19:34 ` Tejun Heo

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