diff mbox

[1/4] cifs: clean up id_mode_to_cifs_acl

Message ID 1350386806-18356-2-git-send-email-jlayton@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Layton Oct. 16, 2012, 11:26 a.m. UTC
Add a label we can goto on error, and get rid of some excess indentation.
Also move to kernel-style comments.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 fs/cifs/cifsacl.c | 53 +++++++++++++++++++++++++----------------------------
 1 file changed, 25 insertions(+), 28 deletions(-)

Comments

Shirish Pargaonkar Oct. 16, 2012, 2:17 p.m. UTC | #1
On Tue, Oct 16, 2012 at 6:26 AM, Jeff Layton <jlayton@redhat.com> wrote:
> Add a label we can goto on error, and get rid of some excess indentation.
> Also move to kernel-style comments.
>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
>  fs/cifs/cifsacl.c | 53 +++++++++++++++++++++++++----------------------------
>  1 file changed, 25 insertions(+), 28 deletions(-)
>
> diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
> index 0955d23..d0b2bfb 100644
> --- a/fs/cifs/cifsacl.c
> +++ b/fs/cifs/cifsacl.c
> @@ -1307,42 +1307,39 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode,
>
>         /* Get the security descriptor */
>         pntsd = get_cifs_acl(CIFS_SB(inode->i_sb), inode, path, &secdesclen);
> -
> -       /* Add three ACEs for owner, group, everyone getting rid of
> -          other ACEs as chmod disables ACEs and set the security descriptor */
> -
>         if (IS_ERR(pntsd)) {
>                 rc = PTR_ERR(pntsd);
>                 cERROR(1, "%s: error %d getting sec desc", __func__, rc);
> -       } else {
> -               /* allocate memory for the smb header,
> -                  set security descriptor request security descriptor
> -                  parameters, and secuirty descriptor itself */
> -
> -               secdesclen = secdesclen < DEFSECDESCLEN ?
> -                                       DEFSECDESCLEN : secdesclen;
> -               pnntsd = kmalloc(secdesclen, GFP_KERNEL);
> -               if (!pnntsd) {
> -                       cERROR(1, "Unable to allocate security descriptor");
> -                       kfree(pntsd);
> -                       return -ENOMEM;
> -               }
> +               goto out;
> +       }
>
> -               rc = build_sec_desc(pntsd, pnntsd, secdesclen, nmode, uid, gid,
> -                                       &aclflag);
> +       /*
> +        * Add three ACEs for owner, group, everyone getting rid of other ACEs
> +        * as chmod disables ACEs and set the security descriptor allocate
> +        * memory for the smb header, set security descriptor request security
> +        * descriptor parameters, and secuirty descriptor itself
> +        */
> +       secdesclen = max_t(u32, secdesclen, DEFSECDESCLEN);
> +       pnntsd = kmalloc(secdesclen, GFP_KERNEL);
> +       if (!pnntsd) {
> +               cERROR(1, "Unable to allocate security descriptor");
> +               kfree(pntsd);
> +               return -ENOMEM;
> +       }
>
> -               cFYI(DBG2, "build_sec_desc rc: %d", rc);
> +       rc = build_sec_desc(pntsd, pnntsd, secdesclen, nmode, uid, gid,
> +                               &aclflag);
>
> -               if (!rc) {
> -                       /* Set the security descriptor */
> -                       rc = set_cifs_acl(pnntsd, secdesclen, inode,
> -                                               path, aclflag);
> -                       cFYI(DBG2, "set_cifs_acl rc: %d", rc);
> -               }
> +       cFYI(DBG2, "build_sec_desc rc: %d", rc);
>
> -               kfree(pnntsd);
> -               kfree(pntsd);
> +       if (!rc) {
> +               /* Set the security descriptor */
> +               rc = set_cifs_acl(pnntsd, secdesclen, inode, path, aclflag);
> +               cFYI(DBG2, "set_cifs_acl rc: %d", rc);
>         }
>
> +       kfree(pnntsd);
> +       kfree(pntsd);
> +out:
>         return rc;
>  }
> --
> 1.7.11.7
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

This looks correct.

Reviewed-by:  Shirish Pargaonkar <shirishpargaonkar@gmail.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index 0955d23..d0b2bfb 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -1307,42 +1307,39 @@  id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode,
 
 	/* Get the security descriptor */
 	pntsd = get_cifs_acl(CIFS_SB(inode->i_sb), inode, path, &secdesclen);
-
-	/* Add three ACEs for owner, group, everyone getting rid of
-	   other ACEs as chmod disables ACEs and set the security descriptor */
-
 	if (IS_ERR(pntsd)) {
 		rc = PTR_ERR(pntsd);
 		cERROR(1, "%s: error %d getting sec desc", __func__, rc);
-	} else {
-		/* allocate memory for the smb header,
-		   set security descriptor request security descriptor
-		   parameters, and secuirty descriptor itself */
-
-		secdesclen = secdesclen < DEFSECDESCLEN ?
-					DEFSECDESCLEN : secdesclen;
-		pnntsd = kmalloc(secdesclen, GFP_KERNEL);
-		if (!pnntsd) {
-			cERROR(1, "Unable to allocate security descriptor");
-			kfree(pntsd);
-			return -ENOMEM;
-		}
+		goto out;
+	}
 
-		rc = build_sec_desc(pntsd, pnntsd, secdesclen, nmode, uid, gid,
-					&aclflag);
+	/*
+	 * Add three ACEs for owner, group, everyone getting rid of other ACEs
+	 * as chmod disables ACEs and set the security descriptor allocate
+	 * memory for the smb header, set security descriptor request security
+	 * descriptor parameters, and secuirty descriptor itself
+	 */
+	secdesclen = max_t(u32, secdesclen, DEFSECDESCLEN);
+	pnntsd = kmalloc(secdesclen, GFP_KERNEL);
+	if (!pnntsd) {
+		cERROR(1, "Unable to allocate security descriptor");
+		kfree(pntsd);
+		return -ENOMEM;
+	}
 
-		cFYI(DBG2, "build_sec_desc rc: %d", rc);
+	rc = build_sec_desc(pntsd, pnntsd, secdesclen, nmode, uid, gid,
+				&aclflag);
 
-		if (!rc) {
-			/* Set the security descriptor */
-			rc = set_cifs_acl(pnntsd, secdesclen, inode,
-						path, aclflag);
-			cFYI(DBG2, "set_cifs_acl rc: %d", rc);
-		}
+	cFYI(DBG2, "build_sec_desc rc: %d", rc);
 
-		kfree(pnntsd);
-		kfree(pntsd);
+	if (!rc) {
+		/* Set the security descriptor */
+		rc = set_cifs_acl(pnntsd, secdesclen, inode, path, aclflag);
+		cFYI(DBG2, "set_cifs_acl rc: %d", rc);
 	}
 
+	kfree(pnntsd);
+	kfree(pntsd);
+out:
 	return rc;
 }