* [patch] ipw2x00: signedness bug handling frame length
@ 2012-01-12 6:34 Dan Carpenter
2012-01-13 10:29 ` Stanislaw Gruszka
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2012-01-12 6:34 UTC (permalink / raw)
To: John W. Linville
Cc: Johannes Berg, Stanislaw Gruszka, Jiri Kosina, Lucas De Marchi,
linux-wireless, kernel-janitors
This is basically just a cleanup. Large positive numbers get counted as
negative but then get implicitly cast to positive again for the checks
that matter.
This does make a small difference in ipw_handle_promiscuous_rx() when we
test "if (unlikely((len + IPW_RX_FRAME_SIZE) > skb_tailroom(rxb->skb)))"
It should return there, but we don't return until a couple lines later
when we test "if (len > IPW_RX_BUF_SIZE - sizeof(struct ipw_rt_hdr)) {".
The difference is that in the second test the sizeof() means that there
is an implied cast to unsigned.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index 018a8de..4fcdac6 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -7848,7 +7848,7 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
* more efficiently than we can parse it. ORDER MATTERS HERE */
struct ipw_rt_hdr *ipw_rt;
- short len = le16_to_cpu(pkt->u.frame.length);
+ unsigned short len = le16_to_cpu(pkt->u.frame.length);
/* We received data from the HW, so stop the watchdog */
dev->trans_start = jiffies;
@@ -8023,7 +8023,7 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
s8 signal = frame->rssi_dbm - IPW_RSSI_TO_DBM;
s8 noise = (s8) le16_to_cpu(frame->noise);
u8 rate = frame->rate;
- short len = le16_to_cpu(pkt->u.frame.length);
+ unsigned short len = le16_to_cpu(pkt->u.frame.length);
struct sk_buff *skb;
int hdr_only = 0;
u16 filter = priv->prom_priv->filter;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch] ipw2x00: signedness bug handling frame length
2012-01-12 6:34 [patch] ipw2x00: signedness bug handling frame length Dan Carpenter
@ 2012-01-13 10:29 ` Stanislaw Gruszka
2012-01-13 10:36 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Stanislaw Gruszka @ 2012-01-13 10:29 UTC (permalink / raw)
To: Dan Carpenter
Cc: John W. Linville, Johannes Berg, Jiri Kosina, Lucas De Marchi,
linux-wireless, kernel-janitors
On Thu, Jan 12, 2012 at 09:34:50AM +0300, Dan Carpenter wrote:
> This is basically just a cleanup. Large positive numbers get counted as
> negative but then get implicitly cast to positive again for the checks
> that matter.
>
> This does make a small difference in ipw_handle_promiscuous_rx() when we
> test "if (unlikely((len + IPW_RX_FRAME_SIZE) > skb_tailroom(rxb->skb)))"
> It should return there, but we don't return until a couple lines later
> when we test "if (len > IPW_RX_BUF_SIZE - sizeof(struct ipw_rt_hdr)) {".
> The difference is that in the second test the sizeof() means that there
> is an implied cast to unsigned.
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Not sure if making it "unsinged int" would be better, but this change is
fine to me as is too.
Reviewed-by: Stanislaw Gruszka <sgruszka@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] ipw2x00: signedness bug handling frame length
2012-01-13 10:29 ` Stanislaw Gruszka
@ 2012-01-13 10:36 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2012-01-13 10:36 UTC (permalink / raw)
To: Stanislaw Gruszka
Cc: John W. Linville, Johannes Berg, Jiri Kosina, Lucas De Marchi,
linux-wireless, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1003 bytes --]
On Fri, Jan 13, 2012 at 11:29:09AM +0100, Stanislaw Gruszka wrote:
> On Thu, Jan 12, 2012 at 09:34:50AM +0300, Dan Carpenter wrote:
> > This is basically just a cleanup. Large positive numbers get counted as
> > negative but then get implicitly cast to positive again for the checks
> > that matter.
> >
> > This does make a small difference in ipw_handle_promiscuous_rx() when we
> > test "if (unlikely((len + IPW_RX_FRAME_SIZE) > skb_tailroom(rxb->skb)))"
> > It should return there, but we don't return until a couple lines later
> > when we test "if (len > IPW_RX_BUF_SIZE - sizeof(struct ipw_rt_hdr)) {".
> > The difference is that in the second test the sizeof() means that there
> > is an implied cast to unsigned.
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> Not sure if making it "unsinged int" would be better, but this change is
> fine to me as is too.
Yeah. You're probably right... Next time, I'll do it that way. ;)
regards,
dan carpenter
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-01-13 10:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-12 6:34 [patch] ipw2x00: signedness bug handling frame length Dan Carpenter
2012-01-13 10:29 ` Stanislaw Gruszka
2012-01-13 10:36 ` 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).