diff options
author | Adrian Bunk <bunk@kernel.org> | 2007-11-14 20:00:01 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-14 21:45:41 -0500 |
commit | be21f0ab0d8f10c90265066603a8d95b6037a6fa (patch) | |
tree | 5aeb6f2a2e62e36a8410ef725ac76fa69ab6a182 /mm | |
parent | d5cd97872dca9b79c31224ca014bcea7ca01f5f1 (diff) |
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 <bunk@kernel.org>
Acked-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/util.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -95,8 +95,8 @@ void *krealloc(const void *p, size_t new_size, gfp_t flags) | |||
95 | return (void *)p; | 95 | return (void *)p; |
96 | 96 | ||
97 | ret = kmalloc_track_caller(new_size, flags); | 97 | ret = kmalloc_track_caller(new_size, flags); |
98 | if (ret) { | 98 | if (ret && p) { |
99 | memcpy(ret, p, min(new_size, ks)); | 99 | memcpy(ret, p, ks); |
100 | kfree(p); | 100 | kfree(p); |
101 | } | 101 | } |
102 | return ret; | 102 | return ret; |