* [PATCH] hwmon: (hih6130) Replace sprintf() with sysfs_emit()
@ 2026-09-06 22:35 Massinissa Ghoul via B4 Relay
2026-09-06 22:43 ` sashiko-bot
2026-09-08 16:14 ` Guenter Roeck
0 siblings, 2 replies; 3+ messages in thread
From: Massinissa Ghoul via B4 Relay @ 2026-09-06 22:35 UTC (permalink / raw)
To: Guenter Roeck; +Cc: linux-hwmon, linux-kernel, Massinissa Ghoul
From: Massinissa Ghoul <massigh680@gmail.com>
Use sysfs_emit() instead of sprintf() in the sysfs show functions
hih6130_temperature_show() and hih6130_humidity_show() to use the
preferred kernel interface for writing to sysfs buffers.
No functional change intended.
Note: Not runtime tested due to lack of hardware.
Signed-off-by: Massinissa Ghoul <massigh680@gmail.com>
---
drivers/hwmon/hih6130.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/hih6130.c b/drivers/hwmon/hih6130.c
index 7984be1e706d..6a79aab5d128 100644
--- a/drivers/hwmon/hih6130.c
+++ b/drivers/hwmon/hih6130.c
@@ -168,7 +168,7 @@ static ssize_t hih6130_temperature_show(struct device *dev,
ret = hih6130_update_measurements(dev);
if (ret < 0)
return ret;
- return sprintf(buf, "%d\n", hih6130->temperature);
+ return sysfs_emit(buf, "%d\n", hih6130->temperature);
}
/**
@@ -189,7 +189,7 @@ static ssize_t hih6130_humidity_show(struct device *dev,
ret = hih6130_update_measurements(dev);
if (ret < 0)
return ret;
- return sprintf(buf, "%d\n", hih6130->humidity);
+ return sysfs_emit(buf, "%d\n", hih6130->humidity);
}
/* sysfs attributes */
---
base-commit: ba08432bda66a7889d8f3d1581dabf10f59b25eb
change-id: 20260907-hwmon-hih6130-sysfs-emit-075116223077
Best regards,
--
Massinissa Ghoul <massigh680@gmail.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] hwmon: (hih6130) Replace sprintf() with sysfs_emit()
2026-09-06 22:35 [PATCH] hwmon: (hih6130) Replace sprintf() with sysfs_emit() Massinissa Ghoul via B4 Relay
@ 2026-09-06 22:43 ` sashiko-bot
2026-09-08 16:14 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-09-06 22:43 UTC (permalink / raw)
To: Massinissa Ghoul; +Cc: linux-hwmon
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The driver performs I2C transfers using a stack-allocated buffer, violating the DMA API and potentially causing memory corruption.
--
commit 8d977f465d31017a7624b9759009bb470f1a65cc
Author: Massinissa Ghoul <massigh680@gmail.com>
hwmon: (hih6130) Replace sprintf() with sysfs_emit()
Use sysfs_emit() instead of sprintf() in the sysfs show functions
hih6130_temperature_show() and hih6130_humidity_show() to use the
preferred kernel interface for writing to sysfs buffers.
> diff --git a/drivers/hwmon/hih6130.c b/drivers/hwmon/hih6130.c
> index 7984be1e706d5..6a79aab5d1285 100644
> --- a/drivers/hwmon/hih6130.c
> +++ b/drivers/hwmon/hih6130.c
> @@ -168,7 +168,7 @@ static ssize_t hih6130_temperature_show(struct device *dev,
> ret = hih6130_update_measurements(dev);
> if (ret < 0)
> return ret;
[Severity: High]
This isn't a bug introduced by this patch, but looking at the call to
hih6130_update_measurements(), is there a DMA-safety issue with how it
performs I2C transfers?
Inside hih6130_update_measurements(), a non-DMA-safe buffer is allocated
on the execution stack:
unsigned char tmp[4];
struct i2c_msg msgs[1] = {
{
.addr = client->addr,
.flags = I2C_M_RD,
.len = 4,
.buf = tmp,
}
};
This stack buffer is then passed directly into I2C functions that may
initiate a DMA operation:
ret = i2c_master_send(client, tmp, hih6130->write_length);
...
ret = i2c_transfer(client->adapter, msgs, 1);
Could this lead to memory corruption or kernel panics if the underlying
I2C controller driver attempts to DMA map this stack memory?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260907-hwmon-hih6130-sysfs-emit-v1-1-a1adb5245d0f@gmail.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hwmon: (hih6130) Replace sprintf() with sysfs_emit()
2026-09-06 22:35 [PATCH] hwmon: (hih6130) Replace sprintf() with sysfs_emit() Massinissa Ghoul via B4 Relay
2026-09-06 22:43 ` sashiko-bot
@ 2026-09-08 16:14 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2026-09-08 16:14 UTC (permalink / raw)
To: Massinissa Ghoul; +Cc: linux-hwmon, linux-kernel
On Mon, Sep 07, 2026 at 12:35:02AM +0200, Massinissa Ghoul wrote:
> From: Massinissa Ghoul <massigh680@gmail.com>
>
> Use sysfs_emit() instead of sprintf() in the sysfs show functions
> hih6130_temperature_show() and hih6130_humidity_show() to use the
> preferred kernel interface for writing to sysfs buffers.
>
> No functional change intended.
>
> Note: Not runtime tested due to lack of hardware.
>
> Signed-off-by: Massinissa Ghoul <massigh680@gmail.com>
Applied.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-08 16:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-06 22:35 [PATCH] hwmon: (hih6130) Replace sprintf() with sysfs_emit() Massinissa Ghoul via B4 Relay
2026-09-06 22:43 ` sashiko-bot
2026-09-08 16:14 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox