Commit 72db61d7 authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman

staging: kpc2000: prevent underflow in cpld_reconfigure()

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: 7dc7967f ("staging: kpc2000: add initial set of Daktronics drivers")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200224103325.hrxdnaeqsthplu42@kili.mountainSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 580f57c2
...@@ -110,10 +110,10 @@ static ssize_t cpld_reconfigure(struct device *dev, ...@@ -110,10 +110,10 @@ static ssize_t cpld_reconfigure(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct kp2000_device *pcard = dev_get_drvdata(dev); struct kp2000_device *pcard = dev_get_drvdata(dev);
long wr_val; unsigned long wr_val;
int rv; int rv;
rv = kstrtol(buf, 0, &wr_val); rv = kstrtoul(buf, 0, &wr_val);
if (rv < 0) if (rv < 0)
return rv; return rv;
if (wr_val > 7) if (wr_val > 7)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment