From patchwork Mon Oct 24 05:37:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongliang Mu X-Patchwork-Id: 8164 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp269375wru; Sun, 23 Oct 2022 22:46:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6g4UCTFQ73uUAKq34VSvpWyjJD0/OD3tr7lfc5SD/GfH9MTDwvtDthmErZxxf19IjUWGHl X-Received: by 2002:a65:4bcf:0:b0:460:c57f:9dad with SMTP id p15-20020a654bcf000000b00460c57f9dadmr26996426pgr.18.1666590363924; Sun, 23 Oct 2022 22:46:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666590363; cv=none; d=google.com; s=arc-20160816; b=aYAUezvldgyzi4L53xRGz7m8X+yr1gNP1XRUny+dIQvLH+Gfmx03cyfaqdq6FKDFIi yMwLTdYEqiWailis3HYGZ/ZWPThjqlUrO6RP0phsh+qkr7XxBeH+uO7MZ14ISk/+Mx3p c954w0NH7M3ouzqLAs2cTmfyadcCn3c5B379GZLbqSpo6B7NGEKILF8wzPn9AFHb8Ymo 6Ek4nFFcT1ShTeSUBm6RmcpshOakOZmTgzeUHyU+JdHA6PR1LpbVnIKMkHQVrwUwYE3n a7TV8DStQV6rySEPJDAr/DBT8NAqS994PuNGW9opuMfE8cRuydmfH9fXlReklKV0lxDY 1l6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=xHbg+pufEWgch7JRh/fUISHaHPUSYdWoG3bdLp710as=; b=SBwbuzxkdHa0e5WEobkSGBnb+trqrwcTuHH/mMaO+d7uJ8z9vtJNNONDN6sGVMooh6 +EMdxKIBSSXlCOvVA5Lor67s1IhzFG2Dz8KhvM5F8aW9UuKuYiRGQDJWqBCrHci1xkmM UUDi9mFh34OWm53TNddZB9/vQ70UobqoxbmyKMPVRCewJHpz5OJ1kJMzDIsTUFjx41CV mYOIiyrPWT1eEbSnSMbsNOCsxJZ7Jm/iKcKG5LP/n9YJJqwcg5PwAELAK0TYzC+2UJnj NupItBeaEa5Fmv+y38+M354UZOWgmWZ0s14yHBLLGgsjP+mhmlrumt0YEpoe/GipoIkm T2sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 70-20020a630249000000b0045f74df51e4si32277562pgc.803.2022.10.23.22.45.51; Sun, 23 Oct 2022 22:46:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230017AbiJXFmR (ORCPT + 99 others); Mon, 24 Oct 2022 01:42:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229667AbiJXFmP (ORCPT ); Mon, 24 Oct 2022 01:42:15 -0400 Received: from hust.edu.cn (mail.hust.edu.cn [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9C26748E9; Sun, 23 Oct 2022 22:42:13 -0700 (PDT) Received: from localhost.localdomain ([172.16.0.254]) (user=dzm91@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 29O5ctoA012184-29O5ctoD012184 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 24 Oct 2022 13:38:59 +0800 From: Dongliang Mu To: Wolfgang Grandegger , Marc Kleine-Budde , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vincent Mailhol , Oliver Hartkopp , =?utf-8?q?Stefan_M=C3=A4tje?= , Andy Shevchenko , Sebastian Andrzej Siewior , =?utf-8?q?Sebastian_W?= =?utf-8?q?=C3=BCrl?= , =?utf-8?q?Uwe_Kleine-?= =?utf-8?q?K=C3=B6nig?= Cc: Dongliang Mu , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] can: mcp251x: fix error handling code in mcp251x_can_probe Date: Mon, 24 Oct 2022 13:37:07 +0800 Message-Id: <20221024053711.696124-1-dzm91@hust.edu.cn> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-FEAS-AUTH-USER: dzm91@hust.edu.cn X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747546657587877027?= X-GMAIL-MSGID: =?utf-8?q?1747546657587877027?= In mcp251x_can_probe, if mcp251x_gpio_setup fails, it forgets to unregister the can device. Fix this by unregistering can device in mcp251x_can_probe. Signed-off-by: Dongliang Mu --- drivers/net/can/spi/mcp251x.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c index c320de474f40..b4b280c0699d 100644 --- a/drivers/net/can/spi/mcp251x.c +++ b/drivers/net/can/spi/mcp251x.c @@ -1415,11 +1415,14 @@ static int mcp251x_can_probe(struct spi_device *spi) ret = mcp251x_gpio_setup(priv); if (ret) - goto error_probe; + goto err_reg_candev; netdev_info(net, "MCP%x successfully initialized.\n", priv->model); return 0; +err_reg_candev: + unregister_candev(net); + error_probe: destroy_workqueue(priv->wq); priv->wq = NULL;