Staging: usbip: Fix the warning of unchecked sscanf return value.
authorElena Oat <oat.elena@gmail.com>
Thu, 27 Feb 2014 10:26:52 +0000 (12:26 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Feb 2014 23:12:11 +0000 (15:12 -0800)
The return value of sscanf in stub_dev.c is not checked. This patch
adds the checking of the return value.

Signed-off-by: Elena Oat <oat.elena@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/usbip/stub_dev.c

index b0bfd3430d4772264572c8b6d9359e798825d228..60a3e3fe4dcb29961eec9bdab1ba1ae6bb9aeffe 100644 (file)
@@ -87,13 +87,16 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,
        int sockfd = 0;
        struct socket *socket;
        ssize_t err = -EINVAL;
+       int rv;
 
        if (!sdev) {
                dev_err(dev, "sdev is null\n");
                return -ENODEV;
        }
 
-       sscanf(buf, "%d", &sockfd);
+       rv = sscanf(buf, "%d", &sockfd);
+       if (rv != 1)
+               return -EINVAL;
 
        if (sockfd != -1) {
                dev_info(dev, "stub up\n");