* [PATCH net-next] sky2: Fix crash inside sky2_rx_clean
@ 2014-11-26 14:13 Mirko Lindner
2014-11-26 18:57 ` Stephen Hemminger
2014-11-26 20:17 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Mirko Lindner @ 2014-11-26 14:13 UTC (permalink / raw)
To: davem, netdev@vger.kernel.org
If sky2->tx_le = pci_alloc_consistent() or sky2->tx_ring = kcalloc() in
sky2_alloc_buffers() fails, sky2->rx_ring = kcalloc() will never be called.
In this error case handling, sky2_rx_clean() is called from within
sky2_free_buffers().
In sky2_rx_clean() we find the following:
...
memset(sky2->rx_le, 0, RX_LE_BYTES);
...
This results in a memset using a NULL pointer and will crash the system.
Signed-off-by: Mirko Lindner <mlindner@marvell.com>
---
drivers/net/ethernet/marvell/sky2.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index 53a1cc5..f8ab220 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -1361,7 +1361,9 @@ static void sky2_rx_clean(struct sky2_port *sky2)
{
unsigned i;
- memset(sky2->rx_le, 0, RX_LE_BYTES);
+ if (sky2->rx_le)
+ memset(sky2->rx_le, 0, RX_LE_BYTES);
+
for (i = 0; i < sky2->rx_pending; i++) {
struct rx_ring_info *re = sky2->rx_ring + i;
--
2.1.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] sky2: Fix crash inside sky2_rx_clean
2014-11-26 14:13 [PATCH net-next] sky2: Fix crash inside sky2_rx_clean Mirko Lindner
@ 2014-11-26 18:57 ` Stephen Hemminger
2014-11-26 20:17 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2014-11-26 18:57 UTC (permalink / raw)
To: Mirko Lindner; +Cc: davem, netdev@vger.kernel.org
On Wed, 26 Nov 2014 15:13:38 +0100
Mirko Lindner <mlindner@marvell.com> wrote:
> If sky2->tx_le = pci_alloc_consistent() or sky2->tx_ring = kcalloc() in
> sky2_alloc_buffers() fails, sky2->rx_ring = kcalloc() will never be called.
> In this error case handling, sky2_rx_clean() is called from within
> sky2_free_buffers().
>
> In sky2_rx_clean() we find the following:
>
> ...
> memset(sky2->rx_le, 0, RX_LE_BYTES);
> ...
>
> This results in a memset using a NULL pointer and will crash the system.
>
> Signed-off-by: Mirko Lindner <mlindner@marvell.com>
This matches my earlier patch, but this one is just as good
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] sky2: Fix crash inside sky2_rx_clean
2014-11-26 14:13 [PATCH net-next] sky2: Fix crash inside sky2_rx_clean Mirko Lindner
2014-11-26 18:57 ` Stephen Hemminger
@ 2014-11-26 20:17 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2014-11-26 20:17 UTC (permalink / raw)
To: mlindner; +Cc: netdev
From: Mirko Lindner <mlindner@marvell.com>
Date: Wed, 26 Nov 2014 15:13:38 +0100
> If sky2->tx_le = pci_alloc_consistent() or sky2->tx_ring = kcalloc() in
> sky2_alloc_buffers() fails, sky2->rx_ring = kcalloc() will never be called.
> In this error case handling, sky2_rx_clean() is called from within
> sky2_free_buffers().
>
> In sky2_rx_clean() we find the following:
>
> ...
> memset(sky2->rx_le, 0, RX_LE_BYTES);
> ...
>
> This results in a memset using a NULL pointer and will crash the system.
>
> Signed-off-by: Mirko Lindner <mlindner@marvell.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-26 20:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-26 14:13 [PATCH net-next] sky2: Fix crash inside sky2_rx_clean Mirko Lindner
2014-11-26 18:57 ` Stephen Hemminger
2014-11-26 20:17 ` David Miller
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).