* [PATCH] Security: selinux - Improvement in code readability when
@ 2016-11-11 8:48 Shailendra Verma
2016-11-12 2:29 ` Paul Moore
0 siblings, 1 reply; 2+ messages in thread
From: Shailendra Verma @ 2016-11-11 8:48 UTC (permalink / raw)
To: Paul Moore, Stephen Smalley, Eric Paris, James Morris,
Serge E. Hallyn, selinux, linux-security-module, linux-kernel,
Shailendra Verma, Shailendra Verma
Cc: vidushi.koul
From: "Shailendra Verma" <shailendra.v@samsung.com>
There is no need to call kfree() if memdup_user() fails, as no memory
was allocated and the error in the error-valued pointer should be returned.
Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
security/selinux/selinuxfs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 72c145d..b6d0a23 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -1166,7 +1166,7 @@ static ssize_t sel_write_bool(struct file *filep, const char __user *buf,
length = -EINVAL;
if (sscanf(page, "%d", &new_value) != 1)
- goto out;
+ goto out1;
if (new_value)
new_value = 1;
@@ -1174,9 +1174,10 @@ static ssize_t sel_write_bool(struct file *filep, const char __user *buf,
bool_pending_values[index] = new_value;
length = count;
+out1:
+ kfree(page);
out:
mutex_unlock(&sel_mutex);
- kfree(page);
return length;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Security: selinux - Improvement in code readability when
2016-11-11 8:48 [PATCH] Security: selinux - Improvement in code readability when Shailendra Verma
@ 2016-11-12 2:29 ` Paul Moore
0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2016-11-12 2:29 UTC (permalink / raw)
To: Shailendra Verma
Cc: Stephen Smalley, Eric Paris, James Morris, Serge E. Hallyn,
selinux, linux-security-module, linux-kernel, Shailendra Verma,
vidushi.koul
On Fri, Nov 11, 2016 at 3:48 AM, Shailendra Verma
<shailendra.v@samsung.com> wrote:
> From: "Shailendra Verma" <shailendra.v@samsung.com>
>
> There is no need to call kfree() if memdup_user() fails, as no memory
> was allocated and the error in the error-valued pointer should be returned.
>
> Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
> ---
> security/selinux/selinuxfs.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Hello Shailendra,
Thank you for your patch, but I prefer the readability of the code as
it currently stands.
--
paul moore
www.paul-moore.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-12 2:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-11 8:48 [PATCH] Security: selinux - Improvement in code readability when Shailendra Verma
2016-11-12 2:29 ` Paul Moore
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).