public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] dsp56k: prevent a harmless underflow
@ 2016-07-13 10:11 Dan Carpenter
  2016-07-13 15:01 ` Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-07-13 10:11 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Greg Kroah-Hartman, linux-kernel, kernel-janitors

There is a mistake here where we don't allow "len" to be zero but we
allow negative lengths.  It's basically harmless in this case, but the
underflow makes my static checker complain.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
index 8bf70e8..50aa9ba 100644
--- a/drivers/char/dsp56k.c
+++ b/drivers/char/dsp56k.c
@@ -325,7 +325,7 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd,
 			if(get_user(bin, &binary->bin) < 0)
 				return -EFAULT;
 		
-			if (len == 0) {
+			if (len <= 0) {
 				return -EINVAL;      /* nothing to upload?!? */
 			}
 			if (len > DSP56K_MAX_BINARY_LENGTH) {

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-13 15:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-13 10:11 [patch] dsp56k: prevent a harmless underflow Dan Carpenter
2016-07-13 15:01 ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox