From: Adrian Bunk Date: Thu, 15 Nov 2007 01:00:01 +0000 (-0800) Subject: fix mm/util.c:krealloc() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=be21f0ab0d8f10c90265066603a8d95b6037a6fa;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git fix mm/util.c:krealloc() Commit ef8b4520bd9f8294ffce9abd6158085bde5dc902 added one NULL check for "p" in krealloc(), but that doesn't seem to be enough since there doesn't seem to be any guarantee that memcpy(ret, NULL, 0) works (spotted by the Coverity checker). For making it clearer what happens this patch also removes the pointless min(). Signed-off-by: Adrian Bunk Acked-by: Christoph Lameter Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/util.c b/mm/util.c index 5f64026cbb4..8f18683825b 100644 --- a/mm/util.c +++ b/mm/util.c @@ -95,8 +95,8 @@ void *krealloc(const void *p, size_t new_size, gfp_t flags) return (void *)p; ret = kmalloc_track_caller(new_size, flags); - if (ret) { - memcpy(ret, p, min(new_size, ks)); + if (ret && p) { + memcpy(ret, p, ks); kfree(p); } return ret;