diff mbox

[14/46] selinux: One function call less in genfs_read() after null pointer detection

Message ID 202d7312-b266-ce9d-8f7a-3e8282c7b0c5@users.sourceforge.net (mailing list archive)
State New, archived
Headers show

Commit Message

SF Markus Elfring Jan. 15, 2017, 3:14 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 14 Jan 2017 17:43:47 +0100

Call the function "kfree" at the end only after it was determined
that the local variable "newgenfs" contained a non-null pointer.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 security/selinux/ss/policydb.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Paul Moore March 23, 2017, 9:54 p.m. UTC | #1
On Sun, Jan 15, 2017 at 10:14 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 14 Jan 2017 17:43:47 +0100
>
> Call the function "kfree" at the end only after it was determined
> that the local variable "newgenfs" contained a non-null pointer.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  security/selinux/ss/policydb.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Merged, thanks.

> diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
> index a12d9166f0e4..5dc31faa601f 100644
> --- a/security/selinux/ss/policydb.c
> +++ b/security/selinux/ss/policydb.c
> @@ -2096,9 +2096,10 @@ static int genfs_read(struct policydb *p, void *fp)
>         }
>         rc = 0;
>  out:
> -       if (newgenfs)
> +       if (newgenfs) {
>                 kfree(newgenfs->fstype);
> -       kfree(newgenfs);
> +               kfree(newgenfs);
> +       }
>         ocontext_destroy(newc, OCON_FSUSE);
>
>         return rc;
> --
> 2.11.0
>
diff mbox

Patch

diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index a12d9166f0e4..5dc31faa601f 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -2096,9 +2096,10 @@  static int genfs_read(struct policydb *p, void *fp)
 	}
 	rc = 0;
 out:
-	if (newgenfs)
+	if (newgenfs) {
 		kfree(newgenfs->fstype);
-	kfree(newgenfs);
+		kfree(newgenfs);
+	}
 	ocontext_destroy(newc, OCON_FSUSE);
 
 	return rc;