Skip to content

Commit f8fd138

Browse files
pchelkin91ij-intel
authored andcommitted
platform/x86: dell_rbu: avoid uninit value usage in packet_size_write()
Ensure the temp value has been properly parsed from the user-provided buffer and initialized to be used in later operations. While at it, prefer a convenient kstrtoul() helper. Found by Linux Verification Center (linuxtesting.org) with Svace static analysis tool. Fixes: ad6ce87 ("[PATCH] dell_rbu: changes in packet update mechanism") Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru> Link: https://patch.msgid.link/20260403134240.604837-1-pchelkin@ispras.ru [ij: add include] Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent 5969c55 commit f8fd138

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/platform/x86/dell/dell_rbu.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
3131

3232
#include <linux/init.h>
33+
#include <linux/kstrtox.h>
3334
#include <linux/module.h>
3435
#include <linux/slab.h>
3536
#include <linux/string.h>
@@ -619,9 +620,12 @@ static ssize_t packet_size_write(struct file *filp, struct kobject *kobj,
619620
char *buffer, loff_t pos, size_t count)
620621
{
621622
unsigned long temp;
623+
624+
if (kstrtoul(buffer, 10, &temp))
625+
return -EINVAL;
626+
622627
spin_lock(&rbu_data.lock);
623628
packet_empty_list();
624-
sscanf(buffer, "%lu", &temp);
625629
if (temp < 0xffffffff)
626630
rbu_data.packetsize = temp;
627631

0 commit comments

Comments
 (0)