lkml.org 
[lkml]   [2016]   [Aug]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[PATCH] Smack: Use memdup_user() rather than duplicating its implementation
    From
    Date
    From: Markus Elfring <elfring@users.sourceforge.net>
    Date: Sun, 21 Aug 2016 20:17:36 +0200

    Reuse existing functionality from memdup_user() instead of keeping
    duplicate source code.

    This issue was detected by using the Coccinelle software.

    Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
    ---
    security/smack/smackfs.c | 11 +++--------
    1 file changed, 3 insertions(+), 8 deletions(-)

    diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
    index e249a66..6492fe9 100644
    --- a/security/smack/smackfs.c
    +++ b/security/smack/smackfs.c
    @@ -2523,14 +2523,9 @@ static ssize_t smk_write_revoke_subj(struct file *file, const char __user *buf,
    if (count == 0 || count > SMK_LONGLABEL)
    return -EINVAL;

    - data = kzalloc(count, GFP_KERNEL);
    - if (data == NULL)
    - return -ENOMEM;
    -
    - if (copy_from_user(data, buf, count) != 0) {
    - rc = -EFAULT;
    - goto out_data;
    - }
    + data = memdup_user(buf, count);
    + if (IS_ERR(data))
    + return PTR_ERR(data);

    cp = smk_parse_smack(data, count);
    if (IS_ERR(cp)) {
    --
    2.9.3
    \
     
     \ /
      Last update: 2016-09-17 09:57    [W:4.038 / U:0.108 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site