Message ID | 20240213173339.3438713-1-florian.fainelli@broadcom.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-63987-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp840470dyb; Tue, 13 Feb 2024 14:21:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV0M7EAmSE02L6FhNnJOrmZ+8NcMtSP9nbcXVTLckYNfpF98hFFpywt3ey+z4V95uyuDcotcnRSB0kYL7Ok5CXynE6u4A== X-Google-Smtp-Source: AGHT+IEFWFBEmc8O9BiDGwgB5eJdnZkh9PIoh8dNUnbC8FtGxyNZI0XJ/G1+cM+Me7jCqeQ9qLAx X-Received: by 2002:a17:906:35c6:b0:a38:9fc3:3d8d with SMTP id p6-20020a17090635c600b00a389fc33d8dmr452238ejb.46.1707862883550; Tue, 13 Feb 2024 14:21:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707862883; cv=pass; d=google.com; s=arc-20160816; b=iGRi3c8eH9N0ttAuYcTzNRHLYT3p9YAFExPddHdrdHtK1UH+jTgfDP8X+RRhmA3AIs akghbvmIINN2ayKR+gPvKXRer3gogArmhhAzkQdZiBML0rOklSA4q48yuBlOQ9qwslY3 mFIuf5Q7IAWS1VAAOArXkpNToJkSkIuXhrHULQeFsHY21nhkyI+8sUS54MiPX3kb0qv3 ltXqU2VABbuKDBuXVh3M2JOfGEhgO1r6GooUM65LPFS7rakhX1LzC/KZC6zNHZsHdQpM Xx9vx6K/Oca4PpgLddH6LRBy/Uhmc9NjtjTpsORELuqs4GSurZd2uixtCJ18hZmLlOQq QyTg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter; bh=stOXF5GSz9Wwyt/H7mQnKV2B0pBOuBd+TVWaGN+dj7k=; fh=36qmeTqZ2QWUQuKtgkcGzbGj7EfCkU5na84jJMaVC9M=; b=O0KrtvUQx7rAHaEhnxpw11z7nDoR9yYQOAQdQ+5cwhZZDRrxqeXjNczx7y7SmnIpvb p8Ft3wdmarnNdRC5NPD0a2gRr8iBxyza6ZOLOaZWaejLF5vInSxT/pHcz8sZ60uOYYch JNIDYDJ1p5lMSDZt3oJn7VmCoImzHCcmuTnILjAQ7hEY3IEW7Mb2/7uqkG5JJiZDfBDN YCPE0GYUuKsMJNfiV7NS1VSXgUCR+FeEmjA0x2F0oNgeeObs9KXdMm39N9tX6YxtXO5j gtmN3ZT9r03JJAV0SA1X/rEhTSzlJborvmT+wWyT1XBMA+Igi/uHvP74DOdszsNLgn59 Rviw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=Jx06xnCv; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-63987-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63987-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com X-Forwarded-Encrypted: i=2; AJvYcCULlx0bliEqocenFzjfRYdau9jVw0a9Pv1IkTgteVMPD3ib85yLXsLZ64UpNBR3aJc4EF8Qv2QbgHi78JhCWIDquiBFEg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id mf11-20020a170906cb8b00b00a3cf5b63575si1223068ejb.452.2024.02.13.14.21.23 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:21:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63987-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=Jx06xnCv; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-63987-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63987-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 27C261F2A59F for <ouuuleilei@gmail.com>; Tue, 13 Feb 2024 17:34:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1632860271; Tue, 13 Feb 2024 17:33:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Jx06xnCv" Received: from relay.smtp-ext.broadcom.com (unknown [192.19.166.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC8155FF0D; Tue, 13 Feb 2024 17:33:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.19.166.228 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707845629; cv=none; b=DEvsE6z4gMKWDIeykqB4A3NKdLU9reeW+i6ffvTCC3+4jIuUfqK1RBhXsbK88eElSVfPwS4aFR+ssoc1DJmd1IknOg32RUj3VuFoD2SL7K+TOWyjJXaZkSdVm2qnItnxO38LJe2jV+Ow0Y1v92gUO7+K2aRNMaRyQJm+++qJNBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707845629; c=relaxed/simple; bh=+IbLm9MJxyBRjvcQtpRgNGFwNLxIam1/AeyzZaiIC90=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=shmEYdkuB5K7U2H7Zl0cfspH/NJo+2BK/oVev0SDMSCDD5NDH/c+jY0747GgKMRHnzG/D4MgY04ZE5UsiqI0dv9nMMk1tPfME6PluahCu/Xx3XQvGx7QQVbnt4faOClEQI6AursjjlxvPfc4hYRoccZku5qnfxac5KlENR4lYWU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=Jx06xnCv; arc=none smtp.client-ip=192.19.166.228 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Received: from mail-lvn-it-01.lvn.broadcom.net (mail-lvn-it-01.lvn.broadcom.net [10.36.132.253]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id B2304C005FFD; Tue, 13 Feb 2024 09:33:40 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com B2304C005FFD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1707845620; bh=+IbLm9MJxyBRjvcQtpRgNGFwNLxIam1/AeyzZaiIC90=; h=From:To:Cc:Subject:Date:From; b=Jx06xnCviIukYYI6tAxq0wkYGV8+XYvrmVl6xhTtxo5gQRblaOUoPv/W3nhEP+d6f 4GOrnwSuTNVxouVjncnL4KElJgw7SjgdWN6Vn4aeoMQCMzIHgFywLlOgwouYgAZkWL MbDZIB1PNsL7V6TckHto8HyD8WcISh2dElMASfGA= Received: from fainelli-desktop.igp.broadcom.net (fainelli-desktop.dhcp.broadcom.net [10.67.48.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail-lvn-it-01.lvn.broadcom.net (Postfix) with ESMTPSA id 2476618041CAC4; Tue, 13 Feb 2024 09:33:39 -0800 (PST) From: Florian Fainelli <florian.fainelli@broadcom.com> To: netdev@vger.kernel.org Cc: Florian Fainelli <florian.fainelli@broadcom.com>, Justin Chen <justin.chen@broadcom.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, bcm-kernel-feedback-list@broadcom.com (open list:BROADCOM ASP 2.0 ETHERNET DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH net] net: bcmasp: Handle RX buffer allocation failure Date: Tue, 13 Feb 2024 09:33:39 -0800 Message-Id: <20240213173339.3438713-1-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790822874928877636 X-GMAIL-MSGID: 1790824031104741792 |
Series |
[net] net: bcmasp: Handle RX buffer allocation failure
|
|
Commit Message
Florian Fainelli
Feb. 13, 2024, 5:33 p.m. UTC
The buffer_pg variable needs to hold an order-5 allocation (32 x
PAGE_SIZE) which, under memory pressure may fail to be allocated. Deal
with that error condition properly to avoid doing a NULL pointer
de-reference in the subsequent call to dma_map_page().
In addition, the err_reclaim_tx error label in bcmasp_netif_init() needs
to ensure that the TX NAPI object is properly deleted, otherwise
unregister_netdev() will spin forever attempting to test and clear
the NAPI_STATE_HASHED bit.
Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 3 +++
1 file changed, 3 insertions(+)
Comments
Hello: This patch was applied to netdev/net.git (main) by Paolo Abeni <pabeni@redhat.com>: On Tue, 13 Feb 2024 09:33:39 -0800 you wrote: > The buffer_pg variable needs to hold an order-5 allocation (32 x > PAGE_SIZE) which, under memory pressure may fail to be allocated. Deal > with that error condition properly to avoid doing a NULL pointer > de-reference in the subsequent call to dma_map_page(). > > In addition, the err_reclaim_tx error label in bcmasp_netif_init() needs > to ensure that the TX NAPI object is properly deleted, otherwise > unregister_netdev() will spin forever attempting to test and clear > the NAPI_STATE_HASHED bit. > > [...] Here is the summary with links: - [net] net: bcmasp: Handle RX buffer allocation failure https://git.kernel.org/netdev/net/c/e5b2e810daf9 You are awesome, thank you!
diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c index 53e542881255..f59557b0cd51 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c @@ -684,6 +684,8 @@ static int bcmasp_init_rx(struct bcmasp_intf *intf) intf->rx_buf_order = get_order(RING_BUFFER_SIZE); buffer_pg = alloc_pages(GFP_KERNEL, intf->rx_buf_order); + if (!buffer_pg) + return -ENOMEM; dma = dma_map_page(kdev, buffer_pg, 0, RING_BUFFER_SIZE, DMA_FROM_DEVICE); @@ -1092,6 +1094,7 @@ static int bcmasp_netif_init(struct net_device *dev, bool phy_connect) return 0; err_reclaim_tx: + netif_napi_del(&intf->tx_napi); bcmasp_reclaim_free_all_tx(intf); err_phy_disconnect: if (phydev)