From patchwork Mon May 31 14:53:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 12289571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98F2AC47083 for ; Mon, 31 May 2021 14:55:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D0A061378 for ; Mon, 31 May 2021 14:55:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234210AbhEaO5U (ORCPT ); Mon, 31 May 2021 10:57:20 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:3356 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234294AbhEaOyy (ORCPT ); Mon, 31 May 2021 10:54:54 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4FtyqX5ffTz66Ql; Mon, 31 May 2021 22:49:28 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 22:53:11 +0800 Received: from thunder-town.china.huawei.com (10.174.177.72) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 22:53:10 +0800 From: Zhen Lei To: Borislav Petkov , Mauro Carvalho Chehab , Tony Luck , James Morse , Robert Richter , Johannes Thumshirn , Ralf Baechle , Dinh Nguyen , Jan Luebbe , Andre Przywara , Channagoud Kadabi , "Venkata Narendra Kumar Gutta" , Andy Gross , Bjorn Andersson , "Khuong Dinh" , York Sun , linux-edac , linux-mips , linux-arm-msm , linux-kernel CC: Zhen Lei Subject: [PATCH v2 1/3] edac: Fix error return code when edac_pci_add_device() fails Date: Mon, 31 May 2021 22:53:00 +0800 Message-ID: <20210531145302.9655-2-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 In-Reply-To: <20210531145302.9655-1-thunder.leizhen@huawei.com> References: <20210531145302.9655-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.177.72] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org When edac_pci_add_device() fails, fix to return -ENODEV from the error handling case instead of 0. The "goto err" in octeon_pci_probe() is removed to simplify code. Signed-off-by: Zhen Lei --- drivers/edac/amd8111_edac.c | 1 + drivers/edac/mpc85xx_edac.c | 1 + drivers/edac/octeon_edac-pci.c | 9 ++------- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/edac/amd8111_edac.c b/drivers/edac/amd8111_edac.c index 7508aa416ddbd7b..16b28da6489177a 100644 --- a/drivers/edac/amd8111_edac.c +++ b/drivers/edac/amd8111_edac.c @@ -480,6 +480,7 @@ static int amd8111_pci_probe(struct pci_dev *dev, if (edac_pci_add_device(pci_info->edac_dev, pci_info->edac_idx) > 0) { printk(KERN_ERR "failed to add edac_pci for %s\n", pci_info->ctl_name); + ret = -ENODEV; goto err_edac_free_ctl; } diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c index 67f7bc3fe5b3b62..312de75e66b851e 100644 --- a/drivers/edac/mpc85xx_edac.c +++ b/drivers/edac/mpc85xx_edac.c @@ -248,6 +248,7 @@ static int mpc85xx_pci_err_probe(struct platform_device *op) if (edac_pci_add_device(pci, pdata->edac_idx) > 0) { edac_dbg(3, "failed edac_pci_add_device()\n"); + res = -ENODEV; goto err; } diff --git a/drivers/edac/octeon_edac-pci.c b/drivers/edac/octeon_edac-pci.c index 28b238eecefcc9d..07995de4ea703ee 100644 --- a/drivers/edac/octeon_edac-pci.c +++ b/drivers/edac/octeon_edac-pci.c @@ -60,7 +60,6 @@ static void octeon_pci_poll(struct edac_pci_ctl_info *pci) static int octeon_pci_probe(struct platform_device *pdev) { struct edac_pci_ctl_info *pci; - int res = 0; pci = edac_pci_alloc_ctl_info(0, "octeon_pci_err"); if (!pci) @@ -76,15 +75,11 @@ static int octeon_pci_probe(struct platform_device *pdev) if (edac_pci_add_device(pci, 0) > 0) { pr_err("%s: edac_pci_add_device() failed\n", __func__); - goto err; + edac_pci_free_ctl_info(pci); + return -ENODEV; } return 0; - -err: - edac_pci_free_ctl_info(pci); - - return res; } static int octeon_pci_remove(struct platform_device *pdev)