Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6498462rwi; Mon, 24 Oct 2022 02:10:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ro6GAU3B8/jxaY+dVq7Ub4XEIHZ8p8oCam7jPQGBKur62CLkDUq5s4/1m/1rBZnYFgnDV X-Received: by 2002:a17:906:4fcd:b0:78d:8059:17c with SMTP id i13-20020a1709064fcd00b0078d8059017cmr27343801ejw.423.1666602631554; Mon, 24 Oct 2022 02:10:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666602631; cv=none; d=google.com; s=arc-20160816; b=r3VOl9YHQ6EeWSD8omytDE70ifGkgpcEJQpfoR8ojJXp6VSoeGzl/L8tlff6EcdOul XaLxAbkwV0xF4t9vv0ym5/IWqyqMpsuWSM7xaL81vqy8XgvpCoqPCxOxRKolT2FSA8JF 7RApGqKs3vgdto/RBE0ZFVOBW6KvMzfyGLG8/m/cyHYlo9H1RlNd8RqNPhyMLG8/LsEz 7BrbLj9Oz4Td/vO5jIVx0lGZZrfQ2ilyr23mmTFWN4fLg1ifiRSPprPtXW8XZRuzAtXK Azh/7pVNJDytDAT2VqpPllboWiri8NlTCT+kPKj5eVmPVOt0f/1oZaoPxhakib8QxVRf RpTw== 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=kfAFAq6pnQ8NuYEg6wo4bQGsV2vWx4QgAGHrOd9qCOo=; b=jQ028gzc9jhEe09TE8oCmlHa4bM0qRI3UybZyrQw/U71aSwh1yN9GRYCewWdegGS6q KheU2zOQNfpNaNjz4jixqwLspf/xb3q3YqBwIA5sLp8zqvt2l97uU0lhTg0oQpgRPvsP JZbo3FwrkJRxwIAc5PkjpeN3xlfXjOjiqlpeMyQMjXNc6fotXDvsSlzEiGfVYB3ScLDy +sFkBCyb+2nPMEhKkh4+PQLrnV2dXH1tGS/y5Kwk7q6NhQ15qpdgltzA7BV/POfA+ipQ JAfxODGLgszyPlazsVMOtUuL2TcWwv9VdT+yG2d4Az0RTGpi2Efsk1prxoFZ/l3e68CH xeNw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa6-20020a170907868600b007836ec6999dsi28412500ejc.904.2022.10.24.02.10.06; Mon, 24 Oct 2022 02:10:31 -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 S230248AbiJXJHw (ORCPT + 99 others); Mon, 24 Oct 2022 05:07:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231128AbiJXJHi (ORCPT ); Mon, 24 Oct 2022 05:07:38 -0400 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 331E012D33; Mon, 24 Oct 2022 02:07:19 -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 29O94ftr027533-29O94ftu027533 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 24 Oct 2022 17:04:45 +0800 From: Dongliang Mu To: Wolfgang Grandegger , Marc Kleine-Budde , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vincent Mailhol , =?UTF-8?q?Stefan=20M=C3=A4tje?= , Andy Shevchenko , Oliver Hartkopp , =?UTF-8?q?Sebastian=20W=C3=BCrl?= , Dongliang Mu , Sebastian Andrzej Siewior , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , =?UTF-8?q?Timo=20Schl=C3=BC=C3=9Fler?= Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] can: mcp251x: fix error handling code in mcp251x_can_probe Date: Mon, 24 Oct 2022 17:02:52 +0800 Message-Id: <20221024090256.717236-1-dzm91@hust.edu.cn> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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. Fixes: 2d52dabbef60 ("can: mcp251x: add GPIO support") Signed-off-by: Dongliang Mu --- v1->v2: add fixes tag 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..00ed46683656 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; -- 2.35.1