Skip to contentSkip to conversation

nvmet: don't check for NULL pointer before kfree in nvmet_host_release

PATCH In review Christoph Hellwig 4 participants 4 messages Jul 18, 2022 – Jul 21, 2022

Subsystems (2)
lore
Share & tools
lore

Christoph Hellwig

author maintainer
#0 lore raw

PATCH 1/1 nvmet: don't check for NULL pointer before kfree in nvmet_host_release

And add an empty line after the variable declaration.

---
 drivers/nvme/target/configfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/target/configfs.c +2 -2
index 1b11f6a83bb6c..79ff382a5b145 100644
@@ -1788,9 +1788,9 @@ static struct configfs_attribute *nvmet_host_attrs[] = {
 static void nvmet_host_release(struct config_item *item)
 {
 	struct nvmet_host *host = to_host(item);
+
 #ifdef CONFIG_NVME_TARGET_AUTH
-	if (host->dhchap_secret)
-		kfree(host->dhchap_secret);
+	kfree(host->dhchap_secret);
 #endif
 	kfree(host);
 }
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Christoph Hellwig

And add an empty line after the variable declaration.

---
  drivers/nvme/target/configfs.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/target/configfs.c +0 -0
index 1b11f6a83bb6c..79ff382a5b145 100644
@@ -1788,9 +1788,9 @@ static struct configfs_attribute *nvmet_host_attrs[] = {
  static void nvmet_host_release(struct config_item *item)

drivers/nvme/target/configfs.c static struct configfs_attribute *nvmet_host_attrs[] = { · line 1796

Quoted 10 lines
drivers/nvme/target/configfs.c +2 -2
  {
  	struct nvmet_host *host = to_host(item);
+
  #ifdef CONFIG_NVME_TARGET_AUTH
-	if (host->dhchap_secret)
-		kfree(host->dhchap_secret);
+	kfree(host->dhchap_secret);
  #endif
  	kfree(host);
  }

Cheers,

Hannes