X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=mm%2Futil.c;h=4735ea48181680405531a91ffc200b57035a5738;hb=f48009c2b34be347f5e9ecac11b75a848cc82b4d;hp=f5712e8964be8a8da2c521361dee71c123689428;hpb=ddc9b34c3b3bc063a7d9eb891ae09b8f49cfb27e;p=firefly-linux-kernel-4.4.55.git diff --git a/mm/util.c b/mm/util.c index f5712e8964be..4735ea481816 100644 --- a/mm/util.c +++ b/mm/util.c @@ -225,15 +225,10 @@ char *strndup_user(const char __user *s, long n) if (length > n) return ERR_PTR(-EINVAL); - p = kmalloc(length, GFP_KERNEL); + p = memdup_user(s, length); - if (!p) - return ERR_PTR(-ENOMEM); - - if (copy_from_user(p, s, length)) { - kfree(p); - return ERR_PTR(-EFAULT); - } + if (IS_ERR(p)) + return p; p[length - 1] = '\0';