All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] w1: Use kfree_sensitive() instead of memset(0) and kfree()
@ 2024-09-30 11:44 Thorsten Blum
  2024-09-30 11:50 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 4+ messages in thread
From: Thorsten Blum @ 2024-09-30 11:44 UTC (permalink / raw)
  To: Krzysztof Kozlowski; +Cc: Thorsten Blum, linux-kernel

Use kfree_sensitive() to simplify w1_unref_slave() and remove the
following Coccinelle/coccicheck warning reported by
kfree_sensitive.cocci:

  WARNING opportunity for kfree_sensitive/kvfree_sensitive

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
Please note: this change assumes that #ifdef DEBUG is no longer needed
and we should always zero out the memory.
---
 drivers/w1/w1.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index d82e86d3ddf6..127694180eb8 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -795,10 +795,7 @@ int w1_unref_slave(struct w1_slave *sl)
 
 		w1_family_notify(BUS_NOTIFY_DEL_DEVICE, sl);
 		device_unregister(&sl->dev);
-		#ifdef DEBUG
-		memset(sl, 0, sizeof(*sl));
-		#endif
-		kfree(sl);
+		kfree_sensitive(sl);
 	}
 	atomic_dec(&dev->refcnt);
 	mutex_unlock(&dev->list_mutex);
-- 
2.46.2


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

end of thread, other threads:[~2024-09-30 13:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-30 11:44 [PATCH] w1: Use kfree_sensitive() instead of memset(0) and kfree() Thorsten Blum
2024-09-30 11:50 ` Krzysztof Kozlowski
2024-09-30 12:15   ` Thorsten Blum
2024-09-30 13:08     ` Thorsten Blum

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.