mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Purva Yeshi <purvayeshi550@gmail.com>
To: Luca Tettamanti <kronos.it@gmail.com>,
	Jean Delvare <jdelvare@suse.com>,
	Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
	Purva Yeshi <purvayeshi550@gmail.com>
Subject: [PATCH] hwmon: asus_atk0110: NULL buf.pointer after free
Date: Fri, 11 Apr 2025 00:04:50 +0530	[thread overview]
Message-ID: <20250410183450.15514-1-purvayeshi550@gmail.com> (raw)

Fix Smatch-detected issue:
drivers/hwmon/asus_atk0110.c:987 atk_enumerate_old_hwmon() error:
double free of 'buf.pointer' (line 966)
drivers/hwmon/asus_atk0110.c:1008 atk_enumerate_old_hwmon() error:
double free of 'buf.pointer' (line 987)

Smatch warns about double free of 'buf.pointer'.
This happens because the same buffer struct is reused multiple times
without resetting the pointer after free. Set buf.pointer = NULL
after each ACPI_FREE to prevent possible use-after-free bugs.

Signed-off-by: Purva Yeshi <purvayeshi550@gmail.com>
---
 drivers/hwmon/asus_atk0110.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
index c80350e499e9..83ee7f25bb8e 100644
--- a/drivers/hwmon/asus_atk0110.c
+++ b/drivers/hwmon/asus_atk0110.c
@@ -964,6 +964,7 @@ static int atk_enumerate_old_hwmon(struct atk_data *data)
 			count++;
 	}
 	ACPI_FREE(buf.pointer);
+	buf.pointer = NULL;
 
 	/* Temperatures */
 	buf.length = ACPI_ALLOCATE_BUFFER;
@@ -985,6 +986,7 @@ static int atk_enumerate_old_hwmon(struct atk_data *data)
 			count++;
 	}
 	ACPI_FREE(buf.pointer);
+	buf.pointer = NULL;
 
 	/* Fans */
 	buf.length = ACPI_ALLOCATE_BUFFER;
@@ -1006,6 +1008,7 @@ static int atk_enumerate_old_hwmon(struct atk_data *data)
 			count++;
 	}
 	ACPI_FREE(buf.pointer);
+	buf.pointer = NULL;
 
 	return count;
 }
-- 
2.34.1


             reply	other threads:[~2025-04-10 18:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-10 18:34 Purva Yeshi [this message]
2025-04-10 20:04 ` Guenter Roeck
2025-04-11  6:59   ` Purva Yeshi

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=20250410183450.15514-1-purvayeshi550@gmail.com \
    --to=purvayeshi550@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=kronos.it@gmail.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®