Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: W_Armin@gmx.de
To: pali@kernel.org
Cc: linux@roeck-us.net, jdelvare@suse.com, linux-hwmon@vger.kernel.org
Subject: [PATCH 2/5] hwmon: (dell-smm) Use strscpy_pad()
Date: Thu, 21 Oct 2021 19:54:44 +0200	[thread overview]
Message-ID: <20211021175447.5380-3-W_Armin@gmx.de> (raw)
In-Reply-To: <20211021175447.5380-1-W_Armin@gmx.de>

From: Armin Wolf <W_Armin@gmx.de>

Using strscpy_pad() allows for fewer memory accesses
since memset() will not unconditionally zero-out
the whole buffer.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/hwmon/dell-smm-hwmon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
index 9773d6c0477a..b0c591bb761a 100644
--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -25,6 +25,7 @@
 #include <linux/platform_device.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/string.h>
 #include <linux/smp.h>
 #include <linux/types.h>
 #include <linux/uaccess.h>
@@ -472,8 +473,7 @@ i8k_ioctl_unlocked(struct file *fp, struct dell_smm_data *data, unsigned int cmd
 		if (restricted && !capable(CAP_SYS_ADMIN))
 			return -EPERM;

-		memset(buff, 0, sizeof(buff));
-		strscpy(buff, data->bios_machineid, sizeof(buff));
+		strscpy_pad(buff, data->bios_machineid, sizeof(buff));
 		break;

 	case I8K_FN_STATUS:
--
2.20.1


  parent reply	other threads:[~2021-10-21 17:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21 17:54 [PATCH 0/5] hwmon: (dell-smm) Miscellaneous Improvments W_Armin
2021-10-21 17:54 ` [PATCH 1/5] hwmon: (dell-smm) Sort includes in alphabetical order W_Armin
2021-10-21 18:16   ` Pali Rohár
2021-10-21 17:54 ` W_Armin [this message]
2021-10-21 18:17   ` [PATCH 2/5] hwmon: (dell-smm) Use strscpy_pad() Pali Rohár
2021-10-21 17:54 ` [PATCH 3/5] hwmon: (dell-smm) Return -ENOIOCTLCMD instead of -EINVAL W_Armin
2021-10-21 18:17   ` Pali Rohár
2021-10-21 17:54 ` [PATCH 4/5] hwmon: (dell-smm) Add Dell Inspiron 3505 config data W_Armin
2021-10-21 18:05   ` Pali Rohár
2021-10-21 18:36     ` Armin Wolf
2021-10-21 18:42       ` Pali Rohár
2021-10-21 17:54 ` [PATCH 5/5] hwmon: (dell-smm) Speed up setting of fan speed W_Armin
2021-10-21 18:14   ` Pali Rohár

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=20211021175447.5380-3-W_Armin@gmx.de \
    --to=w_armin@gmx.de \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=pali@kernel.org \
    /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