* [patch -next] pch_can: off by one bugs
@ 2010-12-20 9:26 Dan Carpenter
2010-12-21 20:41 ` Wolfgang Grandegger
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2010-12-20 9:26 UTC (permalink / raw)
To: Wolfgang Grandegger; +Cc: socketcan-core, netdev, kernel-janitors
priv->tx_enable[] has PCH_TX_OBJ_END elements so this code is
reading and writing one past the end of the array.
Signed-off-by: Dan Carpenter <error27@gmail.com>
diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c
index 8d45fdd..b2c1292 100644
--- a/drivers/net/can/pch_can.c
+++ b/drivers/net/can/pch_can.c
@@ -1077,7 +1077,7 @@ static int pch_can_suspend(struct pci_dev *pdev, pm_message_t state)
pch_can_set_int_enables(priv, PCH_CAN_DISABLE);
/* Save Tx buffer enable state */
- for (i = PCH_TX_OBJ_START; i <= PCH_TX_OBJ_END; i++)
+ for (i = PCH_TX_OBJ_START; i < PCH_TX_OBJ_END; i++)
priv->tx_enable[i] = pch_can_get_rxtx_ir(priv, i, PCH_TX_IFREG);
/* Disable all Transmit buffers */
@@ -1138,7 +1138,7 @@ static int pch_can_resume(struct pci_dev *pdev)
pch_can_set_optmode(priv);
/* Enabling the transmit buffer. */
- for (i = PCH_TX_OBJ_START; i <= PCH_TX_OBJ_END; i++)
+ for (i = PCH_TX_OBJ_START; i < PCH_TX_OBJ_END; i++)
pch_can_set_rxtx(priv, i, priv->tx_enable[i], PCH_TX_IFREG);
/* Configuring the receive buffer and enabling them. */
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch -next] pch_can: off by one bugs
2010-12-20 9:26 [patch -next] pch_can: off by one bugs Dan Carpenter
@ 2010-12-21 20:41 ` Wolfgang Grandegger
2010-12-21 23:58 ` Tomoya MORINAGA
0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Grandegger @ 2010-12-21 20:41 UTC (permalink / raw)
To: Dan Carpenter
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
netdev-u79uwXL29TY76Z2rM5mHXA,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA
Hello,
On 12/20/2010 10:26 AM, Dan Carpenter wrote:
> priv->tx_enable[] has PCH_TX_OBJ_END elements so this code is
> reading and writing one past the end of the array.
>
> Signed-off-by: Dan Carpenter <error27-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
> diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c
> index 8d45fdd..b2c1292 100644
> --- a/drivers/net/can/pch_can.c
> +++ b/drivers/net/can/pch_can.c
> @@ -1077,7 +1077,7 @@ static int pch_can_suspend(struct pci_dev *pdev, pm_message_t state)
> pch_can_set_int_enables(priv, PCH_CAN_DISABLE);
>
> /* Save Tx buffer enable state */
> - for (i = PCH_TX_OBJ_START; i <= PCH_TX_OBJ_END; i++)
> + for (i = PCH_TX_OBJ_START; i < PCH_TX_OBJ_END; i++)
> priv->tx_enable[i] = pch_can_get_rxtx_ir(priv, i, PCH_TX_IFREG);
>
> /* Disable all Transmit buffers */
> @@ -1138,7 +1138,7 @@ static int pch_can_resume(struct pci_dev *pdev)
> pch_can_set_optmode(priv);
>
> /* Enabling the transmit buffer. */
> - for (i = PCH_TX_OBJ_START; i <= PCH_TX_OBJ_END; i++)
> + for (i = PCH_TX_OBJ_START; i < PCH_TX_OBJ_END; i++)
> pch_can_set_rxtx(priv, i, priv->tx_enable[i], PCH_TX_IFREG);
>
> /* Configuring the receive buffer and enabling them. */
>
This fix does not look correct too me. There are much more loop using
"i <= PCH_TX_OBJ_END" and the message numbering is from 1..32. Therefore
using "priv->tx_enable[i - 1]" seems more appropriate to me. Tomaya,
could you please check.
Thanks,
Wolfgang.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch -next] pch_can: off by one bugs
2010-12-21 20:41 ` Wolfgang Grandegger
@ 2010-12-21 23:58 ` Tomoya MORINAGA
0 siblings, 0 replies; 3+ messages in thread
From: Tomoya MORINAGA @ 2010-12-21 23:58 UTC (permalink / raw)
To: Wolfgang Grandegger, Dan Carpenter
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
netdev-u79uwXL29TY76Z2rM5mHXA,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA
On Wednesday, December 22, 2010 5:41 AM, Wolfgang Grandegger wrote:
> This fix does not look correct too me.
I agree with Wolfgang's comments.
> Dan
Thank you for your report.
I will post the patch by this week.
Thanks,
---
Tomoya MORINAGA
OKI SEMICONDUCTOR CO., LTD.
----- Original Message -----
From: "Wolfgang Grandegger" <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
To: "Dan Carpenter" <error27-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: <socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org>; <netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>;
<kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>; "Tomoya MORINAGA"
<tomoya-linux-ECg8zkTtlr0C6LszWs/t0g@public.gmane.org>
Sent: Wednesday, December 22, 2010 5:41 AM
Subject: Re: [patch -next] pch_can: off by one bugs
> Hello,
>
> On 12/20/2010 10:26 AM, Dan Carpenter wrote:
>> priv->tx_enable[] has PCH_TX_OBJ_END elements so this code is
>> reading and writing one past the end of the array.
>>
>> Signed-off-by: Dan Carpenter <error27-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>
>> diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c
>> index 8d45fdd..b2c1292 100644
>> --- a/drivers/net/can/pch_can.c
>> +++ b/drivers/net/can/pch_can.c
>> @@ -1077,7 +1077,7 @@ static int pch_can_suspend(struct pci_dev *pdev,
>> pm_message_t state)
>> pch_can_set_int_enables(priv, PCH_CAN_DISABLE);
>>
>> /* Save Tx buffer enable state */
>> - for (i = PCH_TX_OBJ_START; i <= PCH_TX_OBJ_END; i++)
>> + for (i = PCH_TX_OBJ_START; i < PCH_TX_OBJ_END; i++)
>> priv->tx_enable[i] = pch_can_get_rxtx_ir(priv, i, PCH_TX_IFREG);
>>
>> /* Disable all Transmit buffers */
>> @@ -1138,7 +1138,7 @@ static int pch_can_resume(struct pci_dev *pdev)
>> pch_can_set_optmode(priv);
>>
>> /* Enabling the transmit buffer. */
>> - for (i = PCH_TX_OBJ_START; i <= PCH_TX_OBJ_END; i++)
>> + for (i = PCH_TX_OBJ_START; i < PCH_TX_OBJ_END; i++)
>> pch_can_set_rxtx(priv, i, priv->tx_enable[i], PCH_TX_IFREG);
>>
>> /* Configuring the receive buffer and enabling them. */
>>
>
> This fix does not look correct too me. There are much more loop using
> "i <= PCH_TX_OBJ_END" and the message numbering is from 1..32. Therefore
> using "priv->tx_enable[i - 1]" seems more appropriate to me. Tomaya,
> could you please check.
>
> Thanks,
>
> Wolfgang.
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-12-21 23:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-20 9:26 [patch -next] pch_can: off by one bugs Dan Carpenter
2010-12-21 20:41 ` Wolfgang Grandegger
2010-12-21 23:58 ` Tomoya MORINAGA
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).