]> git.baikalelectronics.ru Git - kernel.git/commit
lib/lru_cache: fix error free handing in lc_create
authorwuchi <wuchi.zero@gmail.com>
Sat, 18 Jun 2022 08:25:21 +0000 (16:25 +0800)
committerakpm <akpm@linux-foundation.org>
Mon, 18 Jul 2022 00:31:37 +0000 (17:31 -0700)
commit76a6ad8e216374a93807b7463c067d235dcd87de
tree97ce4d8ac30d27286030f33d4a650f54d3223c5f
parent63fb2e64f2c0d15e6821f358d9e23e92a06a1d45
lib/lru_cache: fix error free handing in lc_create

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@gmail.com
Signed-off-by: wuchi <wuchi.zero@gmail.com>
Cc: Philipp Reisner <philipp.reisner@linbit.com>
Cc: Lars Ellenberg <lars.ellenberg@linbit.com>
Cc: Christoph Bhmwalder <christoph.boehmwalder@linbit.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/lru_cache.c