Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp107775rdh; Tue, 13 Feb 2024 10:46:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWRXx8LZL8hvcZvDpIEGXCO0jI5b4BVl6TqtGEKvdlFMRr2t0Sk+CB/Ky9fdrmEYX5eJYi2YNwxyCgl521qAZGyCyE85yb865sSkv153Q== X-Google-Smtp-Source: AGHT+IFsv4XoS7gD/08UHgxPYzh8xenRCxvC6ADlZw0MzimqZNTn9RVY3pmidaXHfWXY10umPwim X-Received: by 2002:a17:902:eb88:b0:1d9:143b:eaf with SMTP id q8-20020a170902eb8800b001d9143b0eafmr386021plg.61.1707849979206; Tue, 13 Feb 2024 10:46:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707849979; cv=pass; d=google.com; s=arc-20160816; b=Re6QkOefRWR9z61eRtfEtgyR3jA1za7QOQDqV6AzQzaxNQM55vCYFstlRTGw6HgLua EOYIy66OB2CQx3nucVODlILA5BqbLiCRk0ni3YCC+zdfAgW22Zw+2BbTpYEcwy/sXIzK ikfP/XCo5rWUtqpiwg5N2WKteUxSX7mPOuDUNGvFiKz+Wh51osnedy3spQREThQtme0r kaTYPgEO2Jki79roafRBWU9l1vmQUxHf2CSrP/+Q4VurT6TxEx15j07f+IxWBxVCyZtr EHaRiElX16Uj/48tVeMIEp88X6HZDoey3mWbvDLNyiTwNVafhPvjRtV7+JOcFtjW9ulo qZ0Q== 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=eiJBDGEr8YYE9EvcyUkdkaWNYgRaL3DEpmEJAP2CgvI=; b=WKAlycppS/Y5KhKGR3HgRPfXbeqRkpTBIWNJcsabuK6N2MWsjlQVk0Ad1R6YluI7SJ HzQg3SIEeuLfPyGp4eu3xN5w7h1ax+fjO014D+B8K/5lqaBw9w6/3QLBGd1KFNh7ajrE cLoGRX/mYkEEufwmDzw7RqDrQMpvLPRT8CSPhB3BG77N2K6zGDs6LTvWPaYT1ATrzjYh jxogZSWeXNnXkC9Rh98ptQHb8NqLJvqUPui4/zbUFiQV3woQyT2CxkdcR4bd04p3DG51 xW0rk5C1mVlwe9xJVwc77315BM896P86MhkMn7sPtjEpX7gVxhhdpBLbiNZANgyEYsuf cd7Q==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63987-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com X-Forwarded-Encrypted: i=2; AJvYcCXYycE5kRBdpOn4v4nnzvdKXQvCHjsCEZvD+exbYWEQCHLO63bknyBvKCBlLQl5Kt7m7TsIztbSE8iWiveGpYSLZW6l0T+xfKSY5nmF+w== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l6-20020a170903120600b001d95d1078f7si2344628plh.346.2024.02.13.10.46.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 10:46:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63987-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63987-linux.lists.archive=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 0DD9AB25306 for ; Tue, 13 Feb 2024 17:33:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 506A75FF0C; Tue, 13 Feb 2024 17:33:50 +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 To: netdev@vger.kernel.org Cc: Florian Fainelli , Justin Chen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , 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: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 3 +++ 1 file changed, 3 insertions(+) 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) -- 2.34.1