usbip:usbip_common.c: check return value of sscanf
PATCH 1/1 usbip:usbip_common.c: check return value of sscanf
Added code to check return value of sscanf.
Signed-off-by John de la Garza <[email protected]>
--- drivers/staging/usbip/usbip_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/usbip/usbip_common.c +2 -1
@@ -55,7 +55,8 @@ static ssize_t usbip_debug_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - sscanf(buf, "%lx", &usbip_debug_flag); + if (sscanf(buf, "%lx", &usbip_debug_flag) != 1) + return -EINVAL;return count; }DEVICE_ATTR_RW (usbip_debug);
Signature · 1 line
1.7.10.4
Quoted 1 line · John de la Garza
Added code to check return value of sscanf.
[]
drivers/staging/usbip/usbip_common.c
Quoted 1 line
drivers/staging/usbip/usbip_common.c +0
-0
[]
drivers/staging/usbip/usbip_common.c static ssize_t usbip_debug_store(struct device *dev, · line 59
Quoted 7 lines
drivers/staging/usbip/usbip_common.c +2
-1@@ -55,7 +55,8 @@ static ssize_t usbip_debug_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - sscanf(buf, "%lx", &usbip_debug_flag); + if (sscanf(buf, "%lx", &usbip_debug_flag) != 1) +return -EINVAL ;
Generally, it's probably better to convert these sscanf uses to kstrto<foo>, kstrtoul in this case.