From patchwork Fri Apr 19 16:17:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Peter_M=C3=BCnster?= X-Patchwork-Id: 13636598 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp-out.a16n.net (smtp-out.a16n.net [87.98.181.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9206130E4F; Fri, 19 Apr 2024 16:17:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=87.98.181.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713543487; cv=none; b=NhNZ8Whh1iOCvcBZtd/2W5P9PXzQukoYzJwCZVK9S88NW8YeuUkb9diPAV5gzNlmWt1TkgPBC/SVZHmgERFXX+2f7G9Zc/g9IyrcQ70JvmJO8KguaoMRGNK4/OQosirkj2xBj3Py3MfVmz2eE5CAi8MTA3oiheYiM7zkDmVC2WA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713543487; c=relaxed/simple; bh=Rcg/4O1A9uKCuNadXucsbBu9FuV6I1CCOfD83WpZN04=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=MrPSRjylxs8aNGecOgiKsc/4jX9VLyXrfu2hkJLvl4v9soqcU2kLwBEzprjuegvT18oUqKZzglzXR9RqXgzdAmpAjIBOITuLoPugfuq8CWKttG1pEkYob3uU3nMFm25Vr1cy1E0o/GosWQhr1ukm6WnmNTKl4YLitkaJq9V8p2c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=a16n.net; spf=pass smtp.mailfrom=a16n.net; dkim=pass (2048-bit key) header.d=a16n.net header.i=@a16n.net header.b=LBEbeLZg; arc=none smtp.client-ip=87.98.181.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=a16n.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=a16n.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=a16n.net header.i=@a16n.net header.b="LBEbeLZg" Received: from server.a16n.net (server.a16n.net [82.65.98.121]) by smtp-out.a16n.net (Postfix) with ESMTP id E7B69460567; Fri, 19 Apr 2024 18:17:47 +0200 (CEST) Received: from ws.localdomain (unknown [192.168.13.254]) by server.a16n.net (Postfix) with ESMTPSA id 0EE7880105E; Fri, 19 Apr 2024 18:17:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=a16n.net; s=a16n; t=1713543468; bh=+UZZtAwCL23Ar3uMWUNZyNfVNCG9S/hYoySIwbZwiVI=; h=From:To:Cc:Subject:Date; b=LBEbeLZghWz9xhllGCeTwaR/+bOcJE9WEq639c7V+SZDpGnVej22RTwyJ2eaLKA+M 7mgb12HNN8LNwtvTRseqwcT90XZu/VqyJhdgehD4NoC+A/8OOe64breBV8n6kDgkVz YnZNgeMfymX1So6qDeT28V7dOv5V6Mbxqn9qWEk8t8HOmB+RMixEMg+vI2Dg9bKs+E kNVyv6dwaJPbnX0fGbCFlNfxi2u2JEwSzVeCAaKOUTGMrSuuMd+owEZLQKbB5zz9EE 3qzCsh24L3z3loVcSLLRcTbxjPOiy1lVE8+3mSoL9fJf+2lYx65oeZVDy1pViXQQlb rRw3naip054WA== Received: by ws.localdomain (Postfix, from userid 1000) id DFBAD20682; Fri, 19 Apr 2024 18:17:47 +0200 (CEST) From: =?utf-8?q?Peter_M=C3=BCnster?= To: netdev@vger.kernel.org Cc: stable@vger.kernel.org, Michael Chan Subject: [PATCH net v2] net: b44: set pause params only when interface is up Date: Fri, 19 Apr 2024 18:17:47 +0200 Message-ID: <875xwd1g44.fsf@a16n.net> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Hi, This patch fixes a kernel panic when using netifd. Could you please apply it also to linux-5.15.y at least? TIA and kind regards, b44_free_rings() accesses b44::rx_buffers (and ::tx_buffers) unconditionally, but b44::rx_buffers is only valid when the device is up (they get allocated in b44_open(), and deallocated again in b44_close()), any other time these is just a NULL pointers. So if you try to change the pause params while the network interface is disabled/administratively down, everything explodes (which likely netifd tries to do). Link: https://github.com/openwrt/openwrt/issues/13789 Fixes: 1da177e4c3f4 (Linux-2.6.12-rc2) Reported-by: Peter Münster Suggested-by: Jonas Gorski Signed-off-by: Vaclav Svoboda Tested-by: Peter Münster Signed-off-by: Peter Münster --- drivers/net/ethernet/broadcom/b44.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c index 3e4fb3c3e834..1be6d14030bc 100644 --- a/drivers/net/ethernet/broadcom/b44.c +++ b/drivers/net/ethernet/broadcom/b44.c @@ -2009,12 +2009,14 @@ static int b44_set_pauseparam(struct net_device *dev, bp->flags |= B44_FLAG_TX_PAUSE; else bp->flags &= ~B44_FLAG_TX_PAUSE; - if (bp->flags & B44_FLAG_PAUSE_AUTO) { - b44_halt(bp); - b44_init_rings(bp); - b44_init_hw(bp, B44_FULL_RESET); - } else { - __b44_set_flow_ctrl(bp, bp->flags); + if (netif_running(dev)) { + if (bp->flags & B44_FLAG_PAUSE_AUTO) { + b44_halt(bp); + b44_init_rings(bp); + b44_init_hw(bp, B44_FULL_RESET); + } else { + __b44_set_flow_ctrl(bp, bp->flags); + } } spin_unlock_irq(&bp->lock); -- 2.35.3