2024-03-28 20:00:16

by Nikita Kiryushin

[permalink] [raw]
Subject: [PATCH net-next] tg3: use sysfs_emit() in tg3_show_temp()

Change sprintf() in sysfs show() handler to sysfs_emit(),
as recommended by sysfs documentation.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Nikita Kiryushin <[email protected]>
---
drivers/net/ethernet/broadcom/tg3.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 62ff4381ac83..ee1bc578be84 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -10892,7 +10892,7 @@ static ssize_t tg3_show_temp(struct device *dev,
tg3_ape_scratchpad_read(tp, &temperature, attr->index,
sizeof(temperature));
spin_unlock_bh(&tp->lock);
- return sprintf(buf, "%u\n", temperature * 1000);
+ return sysfs_emit(buf, "%u\n", temperature * 1000);
}


--
2.34.1



2024-03-28 21:49:21

by Michael Chan

[permalink] [raw]
Subject: Re: [PATCH net-next] tg3: use sysfs_emit() in tg3_show_temp()

On Thu, Mar 28, 2024 at 12:56 PM Nikita Kiryushin <[email protected]> wrote:
>
> Change sprintf() in sysfs show() handler to sysfs_emit(),
> as recommended by sysfs documentation.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Nikita Kiryushin <[email protected]>

Reviewed-by: Michael Chan <[email protected]>

Thanks. We should eventually migrate to use
hwmon_device_register_with_info() so that we don't have to deal with
these sysfs strings.


Attachments:
smime.p7s (4.11 kB)
S/MIME Cryptographic Signature