* [PATCH] net: off by one, try #2
@ 2009-02-11 10:01 Roel Kluin
2009-02-11 13:33 ` Jarek Poplawski
0 siblings, 1 reply; 12+ messages in thread
From: Roel Kluin @ 2009-02-11 10:01 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Andrew Morton
Better?
-------------------->8----------------8<-----------------------
With while (x++ < n) { ... } x can reach n+1.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
drivers/net/3c505.c | 4 ++--
drivers/net/irda/mcs7780.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
index 6124605..fb74846 100644
--- a/drivers/net/3c505.c
+++ b/drivers/net/3c505.c
@@ -500,9 +500,9 @@ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb)
pcb->data.raw[i++] = inb_command(dev->base_addr);
if (i > MAX_PCB_DATA)
INVALID_PCB_MSG(i);
- } while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j < 20000);
+ } while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j <= 20000);
spin_unlock_irqrestore(&adapter->lock, flags);
- if (j >= 20000) {
+ if (j > 20000) {
TIMEOUT_MSG(__LINE__);
return false;
}
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
index 7eafdca..b4f4f19 100644
--- a/drivers/net/irda/mcs7780.c
+++ b/drivers/net/irda/mcs7780.c
@@ -585,7 +585,7 @@ static int mcs_speed_change(struct mcs_cb *mcs)
mcs_get_reg(mcs, MCS_RESV_REG, &rval);
} while(cnt++ < 100 && (rval & MCS_IRINTX));
- if(cnt >= 100) {
+ if(cnt > 100) {
IRDA_ERROR("unable to change speed\n");
ret = -EIO;
goto error;
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] net: off by one, try #2
2009-02-11 10:01 [PATCH] net: off by one, try #2 Roel Kluin
@ 2009-02-11 13:33 ` Jarek Poplawski
2009-02-11 14:22 ` Roel Kluin
0 siblings, 1 reply; 12+ messages in thread
From: Jarek Poplawski @ 2009-02-11 13:33 UTC (permalink / raw)
To: Roel Kluin; +Cc: David S. Miller, netdev, Andrew Morton
On 11-02-2009 11:01, Roel Kluin wrote:
> Better?
Yes, but it looks like here is even more...
>
> -------------------->8----------------8<-----------------------
> With while (x++ < n) { ... } x can reach n+1.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> drivers/net/3c505.c | 4 ++--
> drivers/net/irda/mcs7780.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
> index 6124605..fb74846 100644
> --- a/drivers/net/3c505.c
> +++ b/drivers/net/3c505.c
> @@ -500,9 +500,9 @@ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb)
> pcb->data.raw[i++] = inb_command(dev->base_addr);
> if (i > MAX_PCB_DATA)
> INVALID_PCB_MSG(i);
i is also misused here and array can be overriden, so additional
break/return is needed.
Thanks,
Jarek P.
> - } while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j < 20000);
> + } while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j <= 20000);
> spin_unlock_irqrestore(&adapter->lock, flags);
> - if (j >= 20000) {
> + if (j > 20000) {
> TIMEOUT_MSG(__LINE__);
> return false;
> }
> diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
> index 7eafdca..b4f4f19 100644
> --- a/drivers/net/irda/mcs7780.c
> +++ b/drivers/net/irda/mcs7780.c
> @@ -585,7 +585,7 @@ static int mcs_speed_change(struct mcs_cb *mcs)
> mcs_get_reg(mcs, MCS_RESV_REG, &rval);
> } while(cnt++ < 100 && (rval & MCS_IRINTX));
>
> - if(cnt >= 100) {
> + if(cnt > 100) {
> IRDA_ERROR("unable to change speed\n");
> ret = -EIO;
> goto error;
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] net: off by one, try #2
2009-02-11 13:33 ` Jarek Poplawski
@ 2009-02-11 14:22 ` Roel Kluin
2009-02-11 17:14 ` Jarek Poplawski
0 siblings, 1 reply; 12+ messages in thread
From: Roel Kluin @ 2009-02-11 14:22 UTC (permalink / raw)
To: Jarek Poplawski; +Cc: David S. Miller, netdev, Andrew Morton
>> With while (x++ < n) { ... } x can reach n+1.
>
> Yes, but it looks like here is even more...
> i is also misused here and array can be overriden, so additional
> break/return is needed.
Thanks, is this how it should be?
-------------------->8----------------8<-----------------------
With while (x++ < n) { ... } x can reach n+1. As Jarek Poplawski pointed out, array
pcb->data.raw was not correctly used.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
index 6124605..4cf3050 100644
--- a/drivers/net/3c505.c
+++ b/drivers/net/3c505.c
@@ -497,12 +497,15 @@ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb)
do {
j = 0;
while (((stat = get_status(dev->base_addr)) & ACRF) == 0 && j++ < 20000);
- pcb->data.raw[i++] = inb_command(dev->base_addr);
- if (i > MAX_PCB_DATA)
- INVALID_PCB_MSG(i);
- } while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j < 20000);
+ pcb->data.raw[i] = inb_command(dev->base_addr);
+ } while (++i < MAX_PCB_DATA && (stat & ASF_PCB_MASK) != ASF_PCB_END && j <= 20000);
+
spin_unlock_irqrestore(&adapter->lock, flags);
- if (j >= 20000) {
+ if (i >= MAX_PCB_DATA) {
+ INVALID_PCB_MSG(i);
+ return false;
+ }
+ if (j > 20000) {
TIMEOUT_MSG(__LINE__);
return false;
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] net: off by one, try #2
2009-02-11 14:22 ` Roel Kluin
@ 2009-02-11 17:14 ` Jarek Poplawski
2009-02-11 19:33 ` Roel Kluin
0 siblings, 1 reply; 12+ messages in thread
From: Jarek Poplawski @ 2009-02-11 17:14 UTC (permalink / raw)
To: Roel Kluin; +Cc: David S. Miller, netdev, Andrew Morton
On Wed, Feb 11, 2009 at 03:22:52PM +0100, Roel Kluin wrote:
> >> With while (x++ < n) { ... } x can reach n+1.
> >
> > Yes, but it looks like here is even more...
> > i is also misused here and array can be overriden, so additional
> > break/return is needed.
>
> Thanks, is this how it should be?
It looks (almost) OK to me. :-) Except this > 80 line.
On the other hand, I wonder if it's not a good time to make it more
readable; I mean the first while (): length, ";", and maybe ++j
similarly to i now?
BTW, I hope you remember about irda.
Jarek P.
> -------------------->8----------------8<-----------------------
>
> With while (x++ < n) { ... } x can reach n+1. As Jarek Poplawski pointed out, array
> pcb->data.raw was not correctly used.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
> index 6124605..4cf3050 100644
> --- a/drivers/net/3c505.c
> +++ b/drivers/net/3c505.c
> @@ -497,12 +497,15 @@ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb)
> do {
> j = 0;
> while (((stat = get_status(dev->base_addr)) & ACRF) == 0 && j++ < 20000);
> - pcb->data.raw[i++] = inb_command(dev->base_addr);
> - if (i > MAX_PCB_DATA)
> - INVALID_PCB_MSG(i);
> - } while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j < 20000);
> + pcb->data.raw[i] = inb_command(dev->base_addr);
> + } while (++i < MAX_PCB_DATA && (stat & ASF_PCB_MASK) != ASF_PCB_END && j <= 20000);
> +
> spin_unlock_irqrestore(&adapter->lock, flags);
> - if (j >= 20000) {
> + if (i >= MAX_PCB_DATA) {
> + INVALID_PCB_MSG(i);
> + return false;
> + }
> + if (j > 20000) {
> TIMEOUT_MSG(__LINE__);
> return false;
> }
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] net: off by one, try #2
2009-02-11 17:14 ` Jarek Poplawski
@ 2009-02-11 19:33 ` Roel Kluin
2009-02-11 20:27 ` Jarek Poplawski
0 siblings, 1 reply; 12+ messages in thread
From: Roel Kluin @ 2009-02-11 19:33 UTC (permalink / raw)
To: Jarek Poplawski; +Cc: David S. Miller, netdev, Andrew Morton
Jarek Poplawski wrote:
> On Wed, Feb 11, 2009 at 03:22:52PM +0100, Roel Kluin wrote:
>>>> With while (x++ < n) { ... } x can reach n+1.
>>> Yes, but it looks like here is even more...
>>> i is also misused here and array can be overriden, so additional
>>> break/return is needed.
>> Thanks, is this how it should be?
>
> It looks (almost) OK to me. :-) Except this > 80 line.
>
> On the other hand, I wonder if it's not a good time to make it more
> readable; I mean the first while (): length, ";", and maybe ++j
> similarly to i now?
>
> BTW, I hope you remember about irda.
>
> Jarek P.
Thanks again for reviewing, how's this? with irda this time.
-------------------->8----------------8<-----------------------
With while (x++ < n) { ... } x can reach n+1. As Jarek Poplawski pointed out, array
pcb->data.raw was not correctly used.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
index 6124605..4ade64a 100644
--- a/drivers/net/3c505.c
+++ b/drivers/net/3c505.c
@@ -493,15 +493,21 @@ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb)
}
/* read the data */
spin_lock_irqsave(&adapter->lock, flags);
- i = 0;
- do {
- j = 0;
- while (((stat = get_status(dev->base_addr)) & ACRF) == 0 && j++ < 20000);
- pcb->data.raw[i++] = inb_command(dev->base_addr);
- if (i > MAX_PCB_DATA)
- INVALID_PCB_MSG(i);
- } while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j < 20000);
+ for (i = 0; i < MAX_PCB_DATA; i++) {
+ for (j = 0; j < 20000; j++) {
+ stat = get_status(dev->base_addr);
+ if (stat & ACRF)
+ break;
+ }
+ pcb->data.raw[i] = inb_command(dev->base_addr);
+ if (stat & ASF_PCB_MASK == ASF_PCB_END || j >= 20000)
+ break;
+ }
spin_unlock_irqrestore(&adapter->lock, flags);
+ if (i >= MAX_PCB_DATA) {
+ INVALID_PCB_MSG(i);
+ return false;
+ }
if (j >= 20000) {
TIMEOUT_MSG(__LINE__);
return false;
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
index 7eafdca..85e88da 100644
--- a/drivers/net/irda/mcs7780.c
+++ b/drivers/net/irda/mcs7780.c
@@ -585,7 +585,7 @@ static int mcs_speed_change(struct mcs_cb *mcs)
mcs_get_reg(mcs, MCS_RESV_REG, &rval);
} while(cnt++ < 100 && (rval & MCS_IRINTX));
- if(cnt >= 100) {
+ if (cnt > 100) {
IRDA_ERROR("unable to change speed\n");
ret = -EIO;
goto error;
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] net: off by one, try #2
2009-02-11 19:33 ` Roel Kluin
@ 2009-02-11 20:27 ` Jarek Poplawski
2009-02-11 20:58 ` Jarek Poplawski
2009-02-11 21:22 ` [PATCH] IRDA: cnt is off by 1 Roel Kluin
0 siblings, 2 replies; 12+ messages in thread
From: Jarek Poplawski @ 2009-02-11 20:27 UTC (permalink / raw)
To: Roel Kluin; +Cc: David S. Miller, netdev, Andrew Morton
On Wed, Feb 11, 2009 at 08:33:25PM +0100, Roel Kluin wrote:
> Jarek Poplawski wrote:
> > On Wed, Feb 11, 2009 at 03:22:52PM +0100, Roel Kluin wrote:
> >>>> With while (x++ < n) { ... } x can reach n+1.
> >>> Yes, but it looks like here is even more...
> >>> i is also misused here and array can be overriden, so additional
> >>> break/return is needed.
> >> Thanks, is this how it should be?
> >
> > It looks (almost) OK to me. :-) Except this > 80 line.
> >
> > On the other hand, I wonder if it's not a good time to make it more
> > readable; I mean the first while (): length, ";", and maybe ++j
> > similarly to i now?
> >
> > BTW, I hope you remember about irda.
> >
> > Jarek P.
>
> Thanks again for reviewing, how's this? with irda this time.
Hmm... except one bug: "stat & ..." needs "()"...
Roel, please resend once more, but separated: something could go to
stable, but not necessarily together. And add more description,
especially to this 3c505 (here is more changes than 'while (x++ < n)').
Anyway, I hope David will like these "off by one" patches again,
especially after this, and sun3lance one. Good catches!
Cheers,
Jarek P.
> -------------------->8----------------8<-----------------------
>
> With while (x++ < n) { ... } x can reach n+1. As Jarek Poplawski pointed out, array
> pcb->data.raw was not correctly used.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
> index 6124605..4ade64a 100644
> --- a/drivers/net/3c505.c
> +++ b/drivers/net/3c505.c
> @@ -493,15 +493,21 @@ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb)
> }
> /* read the data */
> spin_lock_irqsave(&adapter->lock, flags);
> - i = 0;
> - do {
> - j = 0;
> - while (((stat = get_status(dev->base_addr)) & ACRF) == 0 && j++ < 20000);
> - pcb->data.raw[i++] = inb_command(dev->base_addr);
> - if (i > MAX_PCB_DATA)
> - INVALID_PCB_MSG(i);
> - } while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j < 20000);
> + for (i = 0; i < MAX_PCB_DATA; i++) {
> + for (j = 0; j < 20000; j++) {
> + stat = get_status(dev->base_addr);
> + if (stat & ACRF)
> + break;
> + }
> + pcb->data.raw[i] = inb_command(dev->base_addr);
> + if (stat & ASF_PCB_MASK == ASF_PCB_END || j >= 20000)
> + break;
> + }
> spin_unlock_irqrestore(&adapter->lock, flags);
> + if (i >= MAX_PCB_DATA) {
> + INVALID_PCB_MSG(i);
> + return false;
> + }
> if (j >= 20000) {
> TIMEOUT_MSG(__LINE__);
> return false;
> diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
> index 7eafdca..85e88da 100644
> --- a/drivers/net/irda/mcs7780.c
> +++ b/drivers/net/irda/mcs7780.c
> @@ -585,7 +585,7 @@ static int mcs_speed_change(struct mcs_cb *mcs)
> mcs_get_reg(mcs, MCS_RESV_REG, &rval);
> } while(cnt++ < 100 && (rval & MCS_IRINTX));
>
> - if(cnt >= 100) {
> + if (cnt > 100) {
> IRDA_ERROR("unable to change speed\n");
> ret = -EIO;
> goto error;
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] net: off by one, try #2
2009-02-11 20:27 ` Jarek Poplawski
@ 2009-02-11 20:58 ` Jarek Poplawski
2009-02-11 22:55 ` [PATCH] 3c505: do not set pcb->data.raw beyond its size Roel Kluin
2009-02-11 21:22 ` [PATCH] IRDA: cnt is off by 1 Roel Kluin
1 sibling, 1 reply; 12+ messages in thread
From: Jarek Poplawski @ 2009-02-11 20:58 UTC (permalink / raw)
To: Roel Kluin; +Cc: David S. Miller, netdev, Andrew Morton
On Wed, Feb 11, 2009 at 09:27:55PM +0100, Jarek Poplawski wrote:
> On Wed, Feb 11, 2009 at 08:33:25PM +0100, Roel Kluin wrote:
...
One more thing below...
> > Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> > ---
> > diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
> > index 6124605..4ade64a 100644
> > --- a/drivers/net/3c505.c
> > +++ b/drivers/net/3c505.c
> > @@ -493,15 +493,21 @@ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb)
> > }
> > /* read the data */
> > spin_lock_irqsave(&adapter->lock, flags);
> > - i = 0;
> > - do {
> > - j = 0;
> > - while (((stat = get_status(dev->base_addr)) & ACRF) == 0 && j++ < 20000);
> > - pcb->data.raw[i++] = inb_command(dev->base_addr);
> > - if (i > MAX_PCB_DATA)
> > - INVALID_PCB_MSG(i);
> > - } while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j < 20000);
> > + for (i = 0; i < MAX_PCB_DATA; i++) {
> > + for (j = 0; j < 20000; j++) {
> > + stat = get_status(dev->base_addr);
> > + if (stat & ACRF)
> > + break;
> > + }
> > + pcb->data.raw[i] = inb_command(dev->base_addr);
> > + if (stat & ASF_PCB_MASK == ASF_PCB_END || j >= 20000)
> > + break;
Here is no ++i after breaking the loop, so no need for [--i] later;
please, check this more.
Jarek P.
> > + }
> > spin_unlock_irqrestore(&adapter->lock, flags);
> > + if (i >= MAX_PCB_DATA) {
> > + INVALID_PCB_MSG(i);
> > + return false;
> > + }
> > if (j >= 20000) {
> > TIMEOUT_MSG(__LINE__);
> > return false;
> > diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
> > index 7eafdca..85e88da 100644
> > --- a/drivers/net/irda/mcs7780.c
> > +++ b/drivers/net/irda/mcs7780.c
> > @@ -585,7 +585,7 @@ static int mcs_speed_change(struct mcs_cb *mcs)
> > mcs_get_reg(mcs, MCS_RESV_REG, &rval);
> > } while(cnt++ < 100 && (rval & MCS_IRINTX));
> >
> > - if(cnt >= 100) {
> > + if (cnt > 100) {
> > IRDA_ERROR("unable to change speed\n");
> > ret = -EIO;
> > goto error;
> >
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] IRDA: cnt is off by 1
2009-02-11 20:27 ` Jarek Poplawski
2009-02-11 20:58 ` Jarek Poplawski
@ 2009-02-11 21:22 ` Roel Kluin
2009-02-13 0:42 ` David Miller
1 sibling, 1 reply; 12+ messages in thread
From: Roel Kluin @ 2009-02-11 21:22 UTC (permalink / raw)
To: Jarek Poplawski; +Cc: David S. Miller, netdev, Andrew Morton, samuel
Jarek Poplawski wrote:
> Roel, please resend once more, but separated: something could go to
> stable, but not necessarily together.
Ok, Here's for irda:
------------------------------>8----------------8<------------------------------
If no prior break occurs, cnt reaches 101 after the loop, so we are still able
to change speed when cnt has become 100.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
index 7eafdca..85e88da 100644
--- a/drivers/net/irda/mcs7780.c
+++ b/drivers/net/irda/mcs7780.c
@@ -585,7 +585,7 @@ static int mcs_speed_change(struct mcs_cb *mcs)
mcs_get_reg(mcs, MCS_RESV_REG, &rval);
} while(cnt++ < 100 && (rval & MCS_IRINTX));
- if(cnt >= 100) {
+ if (cnt > 100) {
IRDA_ERROR("unable to change speed\n");
ret = -EIO;
goto error;
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH] 3c505: do not set pcb->data.raw beyond its size
2009-02-11 20:58 ` Jarek Poplawski
@ 2009-02-11 22:55 ` Roel Kluin
2009-02-12 6:37 ` Jarek Poplawski
0 siblings, 1 reply; 12+ messages in thread
From: Roel Kluin @ 2009-02-11 22:55 UTC (permalink / raw)
To: Jarek Poplawski; +Cc: David S. Miller, netdev, Andrew Morton, philb
Many thanks, Jarek,
Is this changelog ok?
------------------------------>8----------------8<------------------------------
Ensure that we do not set pcb->data.raw beyond its size, print an error message
and return false if we attempt to. A timout message was printed one too early.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
index 6124605..a8107f9 100644
--- a/drivers/net/3c505.c
+++ b/drivers/net/3c505.c
@@ -493,21 +493,27 @@ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb)
}
/* read the data */
spin_lock_irqsave(&adapter->lock, flags);
- i = 0;
- do {
- j = 0;
- while (((stat = get_status(dev->base_addr)) & ACRF) == 0 && j++ < 20000);
- pcb->data.raw[i++] = inb_command(dev->base_addr);
- if (i > MAX_PCB_DATA)
- INVALID_PCB_MSG(i);
- } while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j < 20000);
+ for (i = 0; i < MAX_PCB_DATA; i++) {
+ for (j = 0; j < 20000; j++) {
+ stat = get_status(dev->base_addr);
+ if (stat & ACRF)
+ break;
+ }
+ pcb->data.raw[i] = inb_command(dev->base_addr);
+ if ((stat & ASF_PCB_MASK) == ASF_PCB_END || j >= 20000)
+ break;
+ }
spin_unlock_irqrestore(&adapter->lock, flags);
+ if (i >= MAX_PCB_DATA) {
+ INVALID_PCB_MSG(i);
+ return false;
+ }
if (j >= 20000) {
TIMEOUT_MSG(__LINE__);
return false;
}
- /* woops, the last "data" byte was really the length! */
- total_length = pcb->data.raw[--i];
+ /* the last "data" byte was really the length! */
+ total_length = pcb->data.raw[i];
/* safety check total length vs data length */
if (total_length != (pcb->length + 2)) {
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] 3c505: do not set pcb->data.raw beyond its size
2009-02-11 22:55 ` [PATCH] 3c505: do not set pcb->data.raw beyond its size Roel Kluin
@ 2009-02-12 6:37 ` Jarek Poplawski
2009-02-13 0:52 ` David Miller
0 siblings, 1 reply; 12+ messages in thread
From: Jarek Poplawski @ 2009-02-12 6:37 UTC (permalink / raw)
To: Roel Kluin; +Cc: David S. Miller, netdev, Andrew Morton, philb
On Wed, Feb 11, 2009 at 11:55:40PM +0100, Roel Kluin wrote:
> Many thanks, Jarek,
>
> Is this changelog ok?
Yes, the changelog and patch look OK to me.
Thanks,
Jarek P.
> ------------------------------>8----------------8<------------------------------
>
> Ensure that we do not set pcb->data.raw beyond its size, print an error message
> and return false if we attempt to. A timout message was printed one too early.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
> index 6124605..a8107f9 100644
> --- a/drivers/net/3c505.c
> +++ b/drivers/net/3c505.c
> @@ -493,21 +493,27 @@ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb)
> }
> /* read the data */
> spin_lock_irqsave(&adapter->lock, flags);
> - i = 0;
> - do {
> - j = 0;
> - while (((stat = get_status(dev->base_addr)) & ACRF) == 0 && j++ < 20000);
> - pcb->data.raw[i++] = inb_command(dev->base_addr);
> - if (i > MAX_PCB_DATA)
> - INVALID_PCB_MSG(i);
> - } while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j < 20000);
> + for (i = 0; i < MAX_PCB_DATA; i++) {
> + for (j = 0; j < 20000; j++) {
> + stat = get_status(dev->base_addr);
> + if (stat & ACRF)
> + break;
> + }
> + pcb->data.raw[i] = inb_command(dev->base_addr);
> + if ((stat & ASF_PCB_MASK) == ASF_PCB_END || j >= 20000)
> + break;
> + }
> spin_unlock_irqrestore(&adapter->lock, flags);
> + if (i >= MAX_PCB_DATA) {
> + INVALID_PCB_MSG(i);
> + return false;
> + }
> if (j >= 20000) {
> TIMEOUT_MSG(__LINE__);
> return false;
> }
> - /* woops, the last "data" byte was really the length! */
> - total_length = pcb->data.raw[--i];
> + /* the last "data" byte was really the length! */
> + total_length = pcb->data.raw[i];
>
> /* safety check total length vs data length */
> if (total_length != (pcb->length + 2)) {
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] IRDA: cnt is off by 1
2009-02-11 21:22 ` [PATCH] IRDA: cnt is off by 1 Roel Kluin
@ 2009-02-13 0:42 ` David Miller
0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2009-02-13 0:42 UTC (permalink / raw)
To: roel.kluin; +Cc: jarkao2, netdev, akpm, samuel
From: Roel Kluin <roel.kluin@gmail.com>
Date: Wed, 11 Feb 2009 22:22:21 +0100
> If no prior break occurs, cnt reaches 101 after the loop, so we are still able
> to change speed when cnt has become 100.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Applied, thanks Roel.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] 3c505: do not set pcb->data.raw beyond its size
2009-02-12 6:37 ` Jarek Poplawski
@ 2009-02-13 0:52 ` David Miller
0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2009-02-13 0:52 UTC (permalink / raw)
To: jarkao2; +Cc: roel.kluin, netdev, akpm, philb
From: Jarek Poplawski <jarkao2@gmail.com>
Date: Thu, 12 Feb 2009 06:37:15 +0000
> On Wed, Feb 11, 2009 at 11:55:40PM +0100, Roel Kluin wrote:
> > Many thanks, Jarek,
> >
> > Is this changelog ok?
>
> Yes, the changelog and patch look OK to me.
Applied, thanks everyone.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2009-02-13 0:52 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-11 10:01 [PATCH] net: off by one, try #2 Roel Kluin
2009-02-11 13:33 ` Jarek Poplawski
2009-02-11 14:22 ` Roel Kluin
2009-02-11 17:14 ` Jarek Poplawski
2009-02-11 19:33 ` Roel Kluin
2009-02-11 20:27 ` Jarek Poplawski
2009-02-11 20:58 ` Jarek Poplawski
2009-02-11 22:55 ` [PATCH] 3c505: do not set pcb->data.raw beyond its size Roel Kluin
2009-02-12 6:37 ` Jarek Poplawski
2009-02-13 0:52 ` David Miller
2009-02-11 21:22 ` [PATCH] IRDA: cnt is off by 1 Roel Kluin
2009-02-13 0:42 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.