All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] devres: Fix devm_krealloc() allocating memory with wrong size
@ 2024-06-16  9:54 Zijun Hu
  2024-06-16  9:58 ` Greg KH
  2024-06-16 10:02 ` Greg KH
  0 siblings, 2 replies; 6+ messages in thread
From: Zijun Hu @ 2024-06-16  9:54 UTC (permalink / raw)
  To: gregkh, rafael; +Cc: andriy.shevchenko, brgl, linux-kernel, Zijun Hu

Kernel API devm_krealloc() calls alloc_dr() with wrong argument
@total_new_size, and it will cause more memory to be allocated
than required, fixed by using @new_size as alloc_dr()'s argument.

Fixes: f82485722e5d ("devres: provide devm_krealloc()")
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
 drivers/base/devres.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index 3df0025d12aa..1cf87ddf1f55 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -898,7 +898,7 @@ void *devm_krealloc(struct device *dev, void *ptr, size_t new_size, gfp_t gfp)
 	 * taking the lock as most probably the caller uses GFP_KERNEL.
 	 */
 	new_dr = alloc_dr(devm_kmalloc_release,
-			  total_new_size, gfp, dev_to_node(dev));
+			  new_size, gfp, dev_to_node(dev));
 	if (!new_dr)
 		return NULL;
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-06-16 10:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-16  9:54 [PATCH v1] devres: Fix devm_krealloc() allocating memory with wrong size Zijun Hu
2024-06-16  9:58 ` Greg KH
2024-06-16 10:02 ` Greg KH
2024-06-16 10:10   ` quic_zijuhu
2024-06-16 10:17     ` Greg KH
2024-06-16 10:22       ` quic_zijuhu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.