* [patch] staging: dgnc: off by one in dgnc_mgmt_ioctl()
@ 2015-03-10 7:39 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2015-03-10 7:39 UTC (permalink / raw)
To: kernel-janitors
"dgnc_NumBoards" is the number of initialized elements in the
dgnc_Board[] array so the comparison should be ">=" instead of ">" so we
don't read invalid data. We can remove the special handling of the
empty array now that we've fixed this bug.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
index 5544a8e..b89bd59 100644
--- a/drivers/staging/dgnc/dgnc_mgmt.c
+++ b/drivers/staging/dgnc/dgnc_mgmt.c
@@ -153,8 +153,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
if (copy_from_user(&brd, uarg, sizeof(int)))
return -EFAULT;
- if ((brd < 0) || (brd > dgnc_NumBoards) ||
- (dgnc_NumBoards = 0))
+ if (brd < 0 || brd >= dgnc_NumBoards)
return -ENODEV;
memset(&di, 0, sizeof(di));
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-03-10 7:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-10 7:39 [patch] staging: dgnc: off by one in dgnc_mgmt_ioctl() Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).