From: Adrian Bunk 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: Chriustoph Lameter Signed-off-by: Andrew Morton --- mm/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff -puN mm/util.c~fix-mm-utilckrealloc mm/util.c --- a/mm/util.c~fix-mm-utilckrealloc +++ a/mm/util.c @@ -95,8 +95,8 @@ void *krealloc(const void *p, size_t new 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; _