linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] atmel: potential underflow in atmel_set_freq()
@ 2016-05-10 19:21 Dan Carpenter
  2016-05-11 19:03 ` Kalle Valo
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-05-10 19:21 UTC (permalink / raw)
  To: Simon Kelley; +Cc: Kalle Valo, linux-wireless, linux-kernel, kernel-janitors

Smatch complains that we cap the upper bound of "fwrq->m" but not the
lower bound.  I don't know if it can actually happen but it's simple
enough to check for negatives.

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

diff --git a/drivers/net/wireless/atmel/atmel.c b/drivers/net/wireless/atmel/atmel.c
index 8f8f37f..bf2e9a0 100644
--- a/drivers/net/wireless/atmel/atmel.c
+++ b/drivers/net/wireless/atmel/atmel.c
@@ -2275,7 +2275,7 @@ static int atmel_set_freq(struct net_device *dev,
 		fwrq->m = ieee80211_frequency_to_channel(f);
 	}
 	/* Setting by channel number */
-	if ((fwrq->m > 1000) || (fwrq->e > 0))
+	if (fwrq->m < 0 || fwrq->m > 1000 || fwrq->e > 0)
 		rc = -EOPNOTSUPP;
 	else {
 		int channel = fwrq->m;

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

* Re: atmel: potential underflow in atmel_set_freq()
  2016-05-10 19:21 [patch] atmel: potential underflow in atmel_set_freq() Dan Carpenter
@ 2016-05-11 19:03 ` Kalle Valo
  0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2016-05-11 19:03 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Simon Kelley, linux-wireless, linux-kernel, kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Smatch complains that we cap the upper bound of "fwrq->m" but not the
> lower bound.  I don't know if it can actually happen but it's simple
> enough to check for negatives.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks, 1 patch applied to wireless-drivers-next.git:

d9739a26fbca atmel: potential underflow in atmel_set_freq()

-- 
Sent by pwcli
https://patchwork.kernel.org/patch/9061371/

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

end of thread, other threads:[~2016-05-11 19:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-10 19:21 [patch] atmel: potential underflow in atmel_set_freq() Dan Carpenter
2016-05-11 19:03 ` Kalle Valo

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).