[merged mm-nonmm-stable] lib-lru_cache-fix-error-free-handing-in-lc_create.patch removed from -mm tree

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

 



The quilt patch titled
     Subject: lib/lru_cache: fix error free handing in lc_create
has been removed from the -mm tree.  Its filename was
     lib-lru_cache-fix-error-free-handing-in-lc_create.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: wuchi <wuchi.zero@xxxxxxxxx>
Subject: lib/lru_cache: fix error free handing in lc_create
Date: Sat, 18 Jun 2022 16:25:21 +0800

When kmem_cache_alloc in function lc_create returns null, we will
free the memory already allocated. The loop of kmem_cache_free
is wrong, especially:
  i = 0  ==> do wrong loop
  i > 0  ==> do not free element[0]

Link: https://lkml.kernel.org/r/20220618082521.7082-1-wuchi.zero@xxxxxxxxx
Signed-off-by: wuchi <wuchi.zero@xxxxxxxxx>
Cc: Philipp Reisner <philipp.reisner@xxxxxxxxxx>
Cc: Lars Ellenberg <lars.ellenberg@xxxxxxxxxx>
Cc: Christoph Bhmwalder <christoph.boehmwalder@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 lib/lru_cache.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/lib/lru_cache.c~lib-lru_cache-fix-error-free-handing-in-lc_create
+++ a/lib/lru_cache.c
@@ -147,8 +147,8 @@ struct lru_cache *lc_create(const char *
 		return lc;
 
 	/* else: could not allocate all elements, give up */
-	for (i--; i; i--) {
-		void *p = element[i];
+	while (i) {
+		void *p = element[--i];
 		kmem_cache_free(cache, p - e_off);
 	}
 	kfree(lc);
_

Patches currently in -mm which might be from wuchi.zero@xxxxxxxxx are

lib-debugobjects-fix-stat-count-and-optimize-debug_objects_mem_init.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux