]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.4/net-b44-set-pause-params-only-when-interface-is-up.patch
5.4-stable patches
[thirdparty/kernel/stable-queue.git] / queue-5.4 / net-b44-set-pause-params-only-when-interface-is-up.patch
1 From e3eb7dd47bd4806f00e104eb6da092c435f9fb21 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Peter=20M=C3=BCnster?= <pm@a16n.net>
3 Date: Wed, 24 Apr 2024 15:51:52 +0200
4 Subject: net: b44: set pause params only when interface is up
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Peter Münster <pm@a16n.net>
10
11 commit e3eb7dd47bd4806f00e104eb6da092c435f9fb21 upstream.
12
13 b44_free_rings() accesses b44::rx_buffers (and ::tx_buffers)
14 unconditionally, but b44::rx_buffers is only valid when the
15 device is up (they get allocated in b44_open(), and deallocated
16 again in b44_close()), any other time these are just a NULL pointers.
17
18 So if you try to change the pause params while the network interface
19 is disabled/administratively down, everything explodes (which likely
20 netifd tries to do).
21
22 Link: https://github.com/openwrt/openwrt/issues/13789
23 Fixes: 1da177e4c3f4 (Linux-2.6.12-rc2)
24 Cc: stable@vger.kernel.org
25 Reported-by: Peter Münster <pm@a16n.net>
26 Suggested-by: Jonas Gorski <jonas.gorski@gmail.com>
27 Signed-off-by: Vaclav Svoboda <svoboda@neng.cz>
28 Tested-by: Peter Münster <pm@a16n.net>
29 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
30 Signed-off-by: Peter Münster <pm@a16n.net>
31 Reviewed-by: Michael Chan <michael.chan@broadcom.com>
32 Link: https://lore.kernel.org/r/87y192oolj.fsf@a16n.net
33 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
34 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
35 ---
36 drivers/net/ethernet/broadcom/b44.c | 14 ++++++++------
37 1 file changed, 8 insertions(+), 6 deletions(-)
38
39 --- a/drivers/net/ethernet/broadcom/b44.c
40 +++ b/drivers/net/ethernet/broadcom/b44.c
41 @@ -2033,12 +2033,14 @@ static int b44_set_pauseparam(struct net
42 bp->flags |= B44_FLAG_TX_PAUSE;
43 else
44 bp->flags &= ~B44_FLAG_TX_PAUSE;
45 - if (bp->flags & B44_FLAG_PAUSE_AUTO) {
46 - b44_halt(bp);
47 - b44_init_rings(bp);
48 - b44_init_hw(bp, B44_FULL_RESET);
49 - } else {
50 - __b44_set_flow_ctrl(bp, bp->flags);
51 + if (netif_running(dev)) {
52 + if (bp->flags & B44_FLAG_PAUSE_AUTO) {
53 + b44_halt(bp);
54 + b44_init_rings(bp);
55 + b44_init_hw(bp, B44_FULL_RESET);
56 + } else {
57 + __b44_set_flow_ctrl(bp, bp->flags);
58 + }
59 }
60 spin_unlock_irq(&bp->lock);
61