All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Manish Baing" <manishbaing2789@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 7/7] hwmon: it87: Use zero-initialization instead of memset()
Date: Sat, 30 May 2026 22:47:24 +0000	[thread overview]
Message-ID: <20260530224724.A8AD11F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260530221353.159461-8-manishbaing2789@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Replacing memset() with empty brace initialization leaves struct padding bytes uninitialized, causing a KMSAN uninit-value warning when copied via platform_device_add_data().
--

commit 429f8b305f54cb034b99374e3bdaa61a1ba8f424
Author: Manish Baing <manishbaing2789@gmail.com>

hwmon: it87: Use zero-initialization instead of memset()

This commit reduces the scope of 'sio_data' by moving it inside the for-loop
and replacing the explicit memset() with empty brace initialization.

> diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
> index 5fd310662ee43..f3f8d835ff92a 100644
> --- a/drivers/hwmon/it87.c
> +++ b/drivers/hwmon/it87.c
> @@ -3777,7 +3777,6 @@ MODULE_DEVICE_TABLE(dmi, it87_dmi_table);
>  static int __init sm_it87_init(void)
>  {
>  	int sioaddr[2] = { REG_2E, REG_4E };
> -	struct it87_sio_data sio_data;
>  	unsigned short isa_address[2];
>  	bool found = false;
>  	int i, err;
> @@ -3789,7 +3788,7 @@ static int __init sm_it87_init(void)
>  	dmi_check_system(it87_dmi_table);
>  
>  	for (i = 0; i < ARRAY_SIZE(sioaddr); i++) {
> -		memset(&sio_data, 0, sizeof(struct it87_sio_data));
> +		struct it87_sio_data sio_data = { };

[Severity: Medium]
Does replacing memset() with empty brace initialization leave struct padding
bytes uninitialized?

Empty brace initialization is often lowered by compilers to member-wise
zeroing, which skips padding bytes.

When this structure is passed to it87_device_add(), it is copied
byte-by-byte via platform_device_add_data():

drivers/hwmon/it87.c:it87_device_add() {
	...
	err = platform_device_add_data(pdev, sio_data,
				       sizeof(struct it87_sio_data));
	...
}

Because platform_device_add_data() uses kmemdup() to copy the entire size of
the structure, won't reading the uninitialized padding bytes trigger a KMSAN
uninitialized-value warning during driver probe?

>  		isa_address[i] = 0;
>  		err = it87_find(sioaddr[i], &isa_address[i], &sio_data, i);
>  		if (err || isa_address[i] == 0)

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260530221353.159461-1-manishbaing2789@gmail.com?part=7

  reply	other threads:[~2026-05-30 22:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-30 22:13 [PATCH 0/7] hwmon: zero-initialization instead of memset Manish Baing
2026-05-30 22:13 ` [PATCH 1/7] hwmon: drivetemp: Use zero-initialization instead of memset() Manish Baing
2026-05-30 22:17   ` sashiko-bot
2026-05-30 22:13 ` [PATCH 2/7] hwmon: f71882fg: " Manish Baing
2026-05-30 22:18   ` sashiko-bot
2026-05-30 22:13 ` [PATCH 3/7] hwmon: ltc2947-core: " Manish Baing
2026-05-30 22:32   ` sashiko-bot
2026-05-30 22:13 ` [PATCH 4/7] hwmon: nct6683: " Manish Baing
2026-05-30 22:35   ` sashiko-bot
2026-05-30 22:13 ` [PATCH 5/7] hwmon: nct6775-platform: " Manish Baing
2026-05-30 22:37   ` sashiko-bot
2026-05-30 22:13 ` [PATCH 6/7] hwmon: pmbus: adm1266: " Manish Baing
2026-05-30 22:40   ` sashiko-bot
2026-05-30 22:13 ` [PATCH 7/7] hwmon: it87: " Manish Baing
2026-05-30 22:47   ` sashiko-bot [this message]
2026-06-06 19:22   ` Manish Baing

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=20260530224724.A8AD11F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=manishbaing2789@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.