提交 be21f0ab 编写于 作者: A Adrian Bunk 提交者: Linus Torvalds

fix mm/util.c:krealloc()

Commit ef8b4520 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: NAdrian Bunk <bunk@kernel.org>
Acked-by: NChristoph Lameter <clameter@sgi.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 d5cd9787
...@@ -95,8 +95,8 @@ void *krealloc(const void *p, size_t new_size, gfp_t flags) ...@@ -95,8 +95,8 @@ void *krealloc(const void *p, size_t new_size, gfp_t flags)
return (void *)p; return (void *)p;
ret = kmalloc_track_caller(new_size, flags); ret = kmalloc_track_caller(new_size, flags);
if (ret) { if (ret && p) {
memcpy(ret, p, min(new_size, ks)); memcpy(ret, p, ks);
kfree(p); kfree(p);
} }
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册