Skip to content

Commit

Permalink
fix mm/util.c:krealloc()
Browse files Browse the repository at this point in the history
Commit ef8b452 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 <[email protected]>
Acked-by: Christoph Lameter <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
AdrianBunk authored and Linus Torvalds committed Nov 15, 2007
1 parent d5cd978 commit be21f0a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mm/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit be21f0a

Please sign in to comment.