[PATCH] usbip:usbip_common.c: check return value of sscanf

From: John de la Garza
Date: Thu Mar 06 2014 - 18:52:19 EST


Added code to check return value of sscanf.

Signed-off-by: John de la Garza <john@xxxxxxxxx>
---
drivers/staging/usbip/usbip_common.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c
index 4a2aab1..2a11233 100644
--- a/drivers/staging/usbip/usbip_common.c
+++ b/drivers/staging/usbip/usbip_common.c
@@ -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);
--
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/