ext2fs(4): Fix a null dererence and clean an unclear switch

Coverity warned that the switch statement fell through.  While this was
intentional, the pattern wasn't especially clear.  I just changed it to a
conventional if pattern.

Reported by:	Coverity
CIDs:		1375851 (false positive), 1375853
Sponsored by:	Dell EMC Isilon
This commit is contained in:
cem 2017-06-03 22:39:50 +00:00
parent bbbfdaced9
commit ce5521a15b

View File

@ -127,13 +127,18 @@ ext2_sync_inode_from_acl(struct acl *acl, struct inode *ip)
static int
ext4_acl_from_disk(char *value, size_t size, struct acl *acl)
{
const char *end = value + size;
const char *end;
int n, count, s;
if (value == NULL)
return (EINVAL);
end = value + size;
if (((struct ext2_acl_header *)value)->a_version != EXT4_ACL_VERSION)
return (EINVAL);
if (!value || size < sizeof(struct ext2_acl_header))
if (size < sizeof(struct ext2_acl_header))
return (EINVAL);
s = size - sizeof(struct ext2_acl_header);
@ -230,8 +235,7 @@ ext2_getacl_posix1e(struct vop_getacl_args *ap)
error = vn_extattr_get(ap->a_vp, IO_NODELOCKED, attrnamespace, attrname,
&len, value, ap->a_td);
switch (error) {
case ENOATTR:
if (error == ENOATTR) {
switch (ap->a_type) {
case ACL_TYPE_ACCESS:
ap->a_aclp->acl_cnt = 3;
@ -250,22 +254,21 @@ ext2_getacl_posix1e(struct vop_getacl_args *ap)
ap->a_aclp->acl_cnt = 0;
break;
}
case 0:
if (!error) {
error = ext4_acl_from_disk(value, len, ap->a_aclp);
if (error)
goto out;
}
} else if (error != 0)
goto out;
if (error == ENOATTR)
error = 0;
if (ap->a_type == ACL_TYPE_ACCESS)
ext2_sync_acl_from_inode(VTOI(ap->a_vp), ap->a_aclp);
default:
break;
if (!error) {
error = ext4_acl_from_disk(value, len, ap->a_aclp);
if (error)
goto out;
}
if (error == ENOATTR)
error = 0;
if (ap->a_type == ACL_TYPE_ACCESS)
ext2_sync_acl_from_inode(VTOI(ap->a_vp), ap->a_aclp);
out:
free(value, M_TEMP);
return (error);