All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] afs: Fix incorrect error handling in afs_xattr_get_acl()
@ 2019-05-12  7:45 ` David Howells
  0 siblings, 0 replies; 14+ messages in thread
From: David Howells @ 2019-05-12  7:45 UTC (permalink / raw)
  To: colin.king; +Cc: Joe Perches

Fix incorrect error handling in afs_xattr_get_acl() where there appears to
be a redundant assignment before return, but in fact the return should be a
goto to the error handling at the end of the function.

Fixes: 260f082bae6d ("afs: Get an AFS3 ACL as an xattr")
Addresses-Coverity: ("Unused Value")
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Joe Perches <joe@perches.com>
---

 fs/afs/xattr.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/afs/xattr.c b/fs/afs/xattr.c
index c81f85003fc7..b6c44e75b361 100644
--- a/fs/afs/xattr.c
+++ b/fs/afs/xattr.c
@@ -71,11 +71,10 @@ static int afs_xattr_get_acl(const struct xattr_handler *handler,
 	if (ret = 0) {
 		ret = acl->size;
 		if (size > 0) {
-			ret = -ERANGE;
-			if (acl->size > size)
-				return -ERANGE;
-			memcpy(buffer, acl->data, acl->size);
-			ret = acl->size;
+			if (acl->size <= size)
+				memcpy(buffer, acl->data, acl->size);
+			else
+				ret = -ERANGE;
 		}
 		kfree(acl);
 	}

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

end of thread, other threads:[~2019-05-13 10:13 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-12  7:45 [PATCH 1/2] afs: Fix incorrect error handling in afs_xattr_get_acl() David Howells
2019-05-12  7:45 ` David Howells
2019-05-12  7:45 ` [PATCH 2/2] afs: Fix afs_xattr_get_yfs() to not try freeing an error value David Howells
2019-05-12  7:45   ` David Howells
2019-05-12 16:07   ` walter harms
2019-05-12 16:07     ` walter harms
2019-05-12 18:10     ` David Howells
2019-05-12 18:10       ` David Howells
2019-05-12 18:44       ` walter harms
2019-05-12 18:44         ` walter harms
2019-05-12 20:06         ` David Howells
2019-05-12 20:06           ` David Howells
2019-05-13 10:13           ` walter harms
2019-05-13 10:13             ` walter harms

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.