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: 13016670 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C281C3A59D for ; Mon, 24 Oct 2022 05:42:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229997AbiJXFmQ (ORCPT ); Mon, 24 Oct 2022 01:42:16 -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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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;