Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp676148lqo; Thu, 16 May 2024 19:51:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU25QXGx6UK8cwyWIBrAFgQ+yIrK2qCAOl91h1QxpNKLq+gC924tPDp93wwvVbgV8ftiPPeBoHgIah/rtVtPzC/30iAm2dvWL2DavHsKw== X-Google-Smtp-Source: AGHT+IFxw/q//VANBxTCVj/9djVQCklbzi/YnuNksCtrIJVsae7C1LqiUIb8AwFQDD3vr3Kl2FK3 X-Received: by 2002:a17:903:2348:b0:1f0:9951:8491 with SMTP id d9443c01a7336-1f099518974mr59683555ad.29.1715914293277; Thu, 16 May 2024 19:51:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715914293; cv=pass; d=google.com; s=arc-20160816; b=BfQ3szGM5HsgI8f76x2jioaAxNDjeV6juQOaWC/KDPKX93AnoagVE2qrjUw+g9DPr8 WV6Mozyu6JuquyInzqG8FNCfoqxPVVJiqualtK8+Kti5CqRm0sgDSoKaH23ZaKkMVVAt jNXVfQ6CmF+WB4elewyB8oYFlq5W79UCgCpT9yFg+U+ZJpBqB3J7angJONoDedH3KFdX jPKGp1vj7xrVooRHIF5Lb4VLWmqfHNt1n1q+zoykhZbPSKAmlTxHh4IQRXhcZEobiqXN Dd86dpTeOOMN+AfNMgBWyrs7pgLow6hbRoYsRaN8oH+j0bTuKOlMeaN6grmuKSMAlLAt hclQ== 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; bh=463KGa2jvmribgYp0V3Mbh1Q7BI1I/5292+6J9XiUGA=; fh=W8Gm+mBu2g+tyiFm4N/fTrMi+4OqO8jmSbzk/h3k6iQ=; b=yeZlvSHEeRJxKeUk53VNhAq/+tQxOAoWz4Me9akN03MvAabEa6ib/5EbEpMzUnbM7h Lkg60bVXbJ6kyfpb1ERArshbcR9Kn57k9eTQJEcW9uzXGJe8c8FfoJ2BlSKWv/d1IBqp 9nCy7bUr7wLK/Wyq/JPs/GbyzZ7wvdfHCIZYy6VneiZBdpfThMp0blPdeJfybzUZ9ahW hUiztksTjoANESOTknCPTlFKY85ubIESyqsaJ0wQvPuGqSDvpzWPADF1kcYlnJis7Vtr eRCyDDocZYKXWYvzLvmxLUkJRMk5ZEhEftKdlx2z4IbTRnghZo97gqHHCC26BuE65KCM Twdg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=iscas.ac.cn); spf=pass (google.com: domain of linux-kernel+bounces-181711-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181711-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c263a4csi23259535ad.560.2024.05.16.19.51.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 19:51:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181711-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=iscas.ac.cn); spf=pass (google.com: domain of linux-kernel+bounces-181711-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181711-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8AF53282A20 for ; Fri, 17 May 2024 02:51:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 68AF4B672; Fri, 17 May 2024 02:51:23 +0000 (UTC) Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 614FA8F55; Fri, 17 May 2024 02:51:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.81 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715914282; cv=none; b=XZT2FyRtVCNbEF9fBJTOv6hw38LNlg4Mtgfx+i7IDF28F14/jlztmVtiiE6ELdC2buKl7e79uGHT4GMbbc3s9UytcmgVr1BmWKVPKgQ6LjrbnNTC5kdLOG3uraTQeDYMYuUp7iIeQRgGflCuNM6StRW9rTf1gQ+LcG8nE95YhJg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715914282; c=relaxed/simple; bh=zzzCp1QUm1wKcYmoJU9X68oy67/XfeJKxY6LghtApFw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=JduQVZFBlQogMTBZwfpd9/hNV4v8RvSOYylOw+YkYKtfjSawjYWJsgjlzNrbcrsmR3fKF0uVpey1mmkAggfXLsEib/5eJunZ+2oPJWSV5zSAjX4xC74Be6mOzRNrwb9BKa9g4Cj7TQWmHwI9HsT2OAjopXQ6vVSB+YEN2lr9MKI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from localhost (unknown [124.16.138.129]) by APP-03 (Coremail) with SMTP id rQCowAC3v5MIxkZmdCJ_Cw--.63667S2; Fri, 17 May 2024 10:50:49 +0800 (CST) From: Chen Ni To: nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, lorenzo@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Chen Ni Subject: [PATCH net-next v2] net: ethernet: mtk_eth_soc: add missing check for rhashtable_init Date: Fri, 17 May 2024 10:39:22 +0800 Message-Id: <20240517023922.362327-1-nichen@iscas.ac.cn> X-Mailer: git-send-email 2.25.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 X-CM-TRANSID:rQCowAC3v5MIxkZmdCJ_Cw--.63667S2 X-Coremail-Antispam: 1UD129KBjvJXoW7uF1rZrWftF4UWw17ArWxXrb_yoW8AFWDpr 4Yya47ZF1rJw4UWa1kAa1xZFW5Ga1xK34DGFyfZw1Sv345Ar47JF1Utay5ZrW0yrWDKFsI yr1jv3sxCFZ8Jw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkE14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4j 6r4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628v n2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F4 0E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFyl IxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxV AFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j 6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUq38 nUUUUU= X-CM-SenderInfo: xqlfxv3q6l2u1dvotugofq/ Add check for the return value of rhashtable_init() and return the error if it fails in order to catch the error. Fixes: 33fc42de3327 ("net: ethernet: mtk_eth_soc: support creating mac address based offload entries") Signed-off-by: Chen Ni --- Changelog: v1 -> v2: 1. Rewrite the error handling. --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +- drivers/net/ethernet/mediatek/mtk_ppe.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index cae46290a7ae..f9b8956a8726 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -4957,7 +4957,7 @@ static int mtk_probe(struct platform_device *pdev) eth->ppe[i] = mtk_ppe_init(eth, eth->base + ppe_addr, i); - if (!eth->ppe[i]) { + if (IS_ERR_OR_NULL(eth->ppe[i])) { err = -ENOMEM; goto err_deinit_ppe; } diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c index 0acee405a749..4895c6febaf8 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c @@ -884,12 +884,15 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, int index) struct mtk_ppe *ppe; u32 foe_flow_size; void *foe; + int ret; ppe = devm_kzalloc(dev, sizeof(*ppe), GFP_KERNEL); if (!ppe) return NULL; - rhashtable_init(&ppe->l2_flows, &mtk_flow_l2_ht_params); + ret = rhashtable_init(&ppe->l2_flows, &mtk_flow_l2_ht_params); + if (ret) + return ERR_PTR(ret); /* need to allocate a separate device, since it PPE DMA access is * not coherent. -- 2.25.1