atl1: fix oops when changing tx/rx ring params
Subsystems (2)
PATCH 1/1 atl1: fix oops when changing tx/rx ring params
Commit 3f5a2a713aad28480d86b0add00c68484b54febc zeroes out the statistics message block (SMB) and coalescing message block (CMB) when adapter ring resources are freed. This is desirable behavior, but, as a side effect, the commit leads to an oops when atl1_set_ringparam() attempts to alter the number of rx or tx elements in the ring buffer (by using ethtool -G, for example). We don't want SMB or CMB to change during this operation.
Modify atl1_set_ringparam() to preserve SMB and CMB when changing ring parameters.
--- drivers/net/atlx/atl1.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/net/atlx/atl1.c +10 -0
@@ -3504,6 +3504,8 @@ static int atl1_set_ringparam(struct net_device *netdev,struct atl1_rfd_ring rfd_old, rfd_new;struct atl1_rrd_ring rrd_old, rrd_new;struct atl1_ring_header rhdr_old, rhdr_new; +struct atl1_smb smb; +struct atl1_cmb cmb;int err; tpd_old = adapter->tpd_ring;
@@ -3544,11 +3546,19 @@ static int atl1_set_ringparam(struct net_device *netdev, adapter->rrd_ring = rrd_old; adapter->tpd_ring = tpd_old; adapter->ring_header = rhdr_old; +/* +* Save SMB and CMB, since atl1_free_ring_resources +* will clear them. +*/ + smb = adapter->smb; + cmb = adapter->cmb;atl1_free_ring_resources (adapter); adapter->rfd_ring = rfd_new; adapter->rrd_ring = rrd_new; adapter->tpd_ring = tpd_new; adapter->ring_header = rhdr_new; + adapter->smb = smb; + adapter->cmb = cmb; err =atl1_up (adapter);if (err)
Signature · 1 line
1.7.2.3
David Miller
maintainerFrom: "J. K. Cliburn" <[email protected]>
Date: Sat, 1 Jan 2011 09:02:12 -0600
Quoted 8 lines
Commit
3f5a2a713aad28480d86b0add00c68484b54febczeroes out the statistics message block (SMB) and coalescing message block (CMB) when adapter ring resources are freed. This is desirable behavior, but, as a side effect, the commit leads to an oops whenatl1_set_ringparam()attempts to alter the number of rx or tx elements in the ring buffer (by using ethtool -G, for example). We don't want SMB or CMB to change during this operation.
Quoted 6 lines
Modify
atl1_set_ringparam()to preserve SMB and CMB when changing ring parameters.Signed-off-by Jay Cliburn <[email protected]>Reported-by Tõnu Raitviir <[email protected]>
I'll apply this, thanks Jay.
Quoted 32 lines · J. K. Cliburn
Commit
3f5a2a713aad28480d86b0add00c68484b54febczeroes out the statistics message block (SMB) and coalescing message block (CMB) when adapter ring resources are freed. This is desirable behavior, but, as a side effect, the commit leads to an oops whenatl1_set_ringparam()attempts to alter the number of rx or tx elements in the ring buffer (by using ethtool -G, for example). We don't want SMB or CMB to change during this operation.Modify
atl1_set_ringparam()to preserve SMB and CMB when changing ring parameters.Signed-off-by Jay Cliburn <[email protected]>Reported-by Tõnu Raitviir <[email protected]>---
drivers/net/atlx/atl1.c | 10 ++++++++++1 files changed, 10 insertions(+), 0 deletions(-)drivers/net/atlx/atl1.c +2
-0@@ -3504,6 +3504,8 @@ static int atl1_set_ringparam(struct net_device *netdev, struct atl1_rfd_ring rfd_old, rfd_new; struct atl1_rrd_ring rrd_old, rrd_new; struct atl1_ring_header rhdr_old, rhdr_new; + struct atl1_smb smb; + struct atl1_cmb cmb; int err; tpd_old = adapter->tpd_ring;
drivers/net/atlx/atl1.c static int atl1_set_ringparam(struct net_device *netdev, · line 3555
Quoted 10 lines
drivers/net/atlx/atl1.c +6
-0@@ -3544,11 +3546,19 @@ static int atl1_set_ringparam(struct net_device *netdev, adapter->rrd_ring = rrd_old; adapter->tpd_ring = tpd_old; adapter->ring_header = rhdr_old; + /* + * Save SMB and CMB, since atl1_free_ring_resources + * will clear them. + */ + smb = adapter->smb; + cmb = adapter->cmb; atl1_free_ring_resources(adapter);
Hum, unless I'm missing something atl1_free_ring_resources frees the whole ring_header->dma block which contains both SMB and CMB.
drivers/net/atlx/atl1.c static int atl1_set_ringparam(struct net_device *netdev, · line 3561
Quoted 6 lines
drivers/net/atlx/atl1.c +2
-0adapter->rfd_ring = rfd_new; adapter->rrd_ring = rrd_new; adapter->tpd_ring = tpd_new; adapter->ring_header = rhdr_new; + adapter->smb = smb; + adapter->cmb = cmb;
So here you're using pointers to freed memory.
In order to preserve the stats you'd have to copy the structure.
Luca
Quoted 2 lines · Luca Tettamanti
So here you're using pointers to freed memory.
In order to preserve the stats you'd have to copy the structure.
Doh. I still haven't recovered from all the partying ;-) Sorry for the noise...
L