All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thorsten Blum <thorsten.blum@linux.dev>
To: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Thorsten Blum <thorsten.blum@linux.dev>, linux-kernel@vger.kernel.org
Subject: [PATCH] w1: Use kfree_sensitive() instead of memset(0) and kfree()
Date: Mon, 30 Sep 2024 13:44:04 +0200	[thread overview]
Message-ID: <20240930114404.80910-2-thorsten.blum@linux.dev> (raw)

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


             reply	other threads:[~2024-09-30 11:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-30 11:44 Thorsten Blum [this message]
2024-09-30 11:50 ` [PATCH] w1: Use kfree_sensitive() instead of memset(0) and kfree() Krzysztof Kozlowski
2024-09-30 12:15   ` Thorsten Blum
2024-09-30 13:08     ` Thorsten Blum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240930114404.80910-2-thorsten.blum@linux.dev \
    --to=thorsten.blum@linux.dev \
    --cc=krzk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.