[2.6 patch] fix mm/util.c:krealloc()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <[email protected]>

---
--- linux-2.6/mm/util.c.old	2007-10-19 15:10:43.000000000 +0200
+++ linux-2.6/mm/util.c	2007-10-19 15:32:01.000000000 +0200
@@ -94,10 +94,10 @@ void *krealloc(const void *p, size_t new
 	if (ks >= new_size)
 		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;
 }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux