Skip to contentSkip to conversation

nfsd: sign conversion obscuring errors in nfsd_set_posix_acl()

PATCH In review Florin Malita 2 participants 2 messages May 16, 2006 NFS server

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfsd: sign conversion obscuring errors in nfsd_set_posix_acl()

Assigning the result of posix_acl_to_xattr() to an unsigned data type (size/size_t) obscures possible errors.

Coverity CID: 1206.

---

fs/nfsd/vfs.c +3 -4
index 6aa92d0..1d65f13 100644
@@ -1922,11 +1922,10 @@ nfsd_set_posix_acl(struct svc_fh *fhp, i
 		value = kmalloc(size, GFP_KERNEL);
 		if (!value)
 			return -ENOMEM;
-		size = posix_acl_to_xattr(acl, value, size);
-		if (size < 0) {
-			error = size;
+		error = posix_acl_to_xattr(acl, value, size);
+		if (error < 0)
 			goto getout;
-		}
+		size = error;
 	} else
 		size = 0;
 
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · On Monday May 15, [email protected] wrote:

Assigning the result of posix_acl_to_xattr() to an unsigned data type (size/size_t) obscures possible errors.

Coverity CID: 1206.

Thanks.
This is non-critical as posix_acl_to_xattr won't actually return an error here (with current code anyway), but it is certainly worth fixing.

The fact that posix_acl_to_xattr takes a 'size_t' for size and returns a int is a bit bothersome... oh well.

NeilBrown

Quoted 24 lines

---

fs/nfsd/vfs.c +3 -4
index 6aa92d0..1d65f13 100644
@@ -1922,11 +1922,10 @@ nfsd_set_posix_acl(struct svc_fh *fhp, i
 		value = kmalloc(size, GFP_KERNEL);
 		if (!value)
 			return -ENOMEM;
-		size = posix_acl_to_xattr(acl, value, size);
-		if (size < 0) {
-			error = size;
+		error = posix_acl_to_xattr(acl, value, size);
+		if (error < 0)
 			goto getout;
-		}
+		size = error;
 	} else
 		size = 0;