]> git.baikalelectronics.ru Git - kernel.git/commitdiff
staging: kpc2000: prevent underflow in cpld_reconfigure()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 24 Feb 2020 10:33:25 +0000 (13:33 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Mar 2020 06:52:31 +0000 (07:52 +0100)
This function should not allow negative values of "wr_val".  If
negatives are allowed then capping the upper bound at 7 is
meaningless.  Let's make it unsigned.

Fixes: ed73d5d856bc ("staging: kpc2000: add initial set of Daktronics drivers")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200224103325.hrxdnaeqsthplu42@kili.mountain
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/kpc2000/kpc2000/core.c

index 93cf28febdf60f6923c7bc8c507e418204f027e8..7b00d7069e21971963216d645885118f368d4e98 100644 (file)
@@ -110,10 +110,10 @@ static ssize_t cpld_reconfigure(struct device *dev,
                                const char *buf, size_t count)
 {
        struct kp2000_device *pcard = dev_get_drvdata(dev);
-       long wr_val;
+       unsigned long wr_val;
        int rv;
 
-       rv = kstrtol(buf, 0, &wr_val);
+       rv = kstrtoul(buf, 0, &wr_val);
        if (rv < 0)
                return rv;
        if (wr_val > 7)