Message ID | 1668396306-47940-1-git-send-email-zhangchangzhong@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1937583wru; Sun, 13 Nov 2022 19:14:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf5/+iLYqDAOJN49PWTPjk1bK4zWV6u4X0HFIVUoInzUbUv0/fyu2/sAfQj7+PQlYB2MjZR8 X-Received: by 2002:a05:6402:1247:b0:461:5542:6884 with SMTP id l7-20020a056402124700b0046155426884mr9333118edw.390.1668395698155; Sun, 13 Nov 2022 19:14:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668395698; cv=none; d=google.com; s=arc-20160816; b=thl0wrHeWIh5nzLEDFLeOLBzSDUjrN3S6YfIw3Pigv092xscvqQThyBef4zB7H2ZiA mHXmZOPVRq/3r3tfRTliIRJWNFj0Y1XOMGbQvoSKeS5lbdiERx3nmYaYuQViFbqulksU hDPu+D+3N5NmtMuD8tT5PUSYkZUbS1Lgb+4c4WxlFvy7B6lPyhqCWk/8B47f2YbW4csx EVNy+2H6g7CBwPIzezoMk8x4Wuxy0mOPzlSnWPTxwdWn9J/ANicZSYQXFymRsUinywz3 q2lKOPTcrmyh+UTFmexDlP71YUNKidvAvx9Pz8HZcJ6maSbvKNen0cjAFOUwoikyQ5iK ThBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=Pjqg01jJ5s6AM1eDC3cHasOx+JfKRrr/Kni8xLUy7hw=; b=K6dtelnVItnktYbncuXiidrYjUWX1N1QCoESChhR9DcKN9FzRFxWbDjgrU50wwkEtd wQ/xbSyjRO5ltwa34yCyi+C1Gaz/AsrjpxqfbPUIqn63ZX6qMAPxpCOJIfE7tQklTbQi P/D6wOcBXZF5eSZaXguNoQ51sCGXolOaLOPiqjABWGp2WAeoaRdrGqs1k3WW2hfqI6Br EvhRKpJmZLVjT0waw8RPwkLYCoVwkLmhGiWnqiJF4b7TQBqaC37R39YuW30ZRzaZ1ISq eqUTHFG9CuMAaCKj8TF5UULMHvhjtgkAPO+TSnBXqvZAyabO7TOIYKbzKUc+hgvX3Zkr cTbg== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga23-20020a1709070c1700b0078dd12d0a9bsi8228557ejc.875.2022.11.13.19.14.35; Sun, 13 Nov 2022 19:14:58 -0800 (PST) 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235741AbiKNDE6 (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Sun, 13 Nov 2022 22:04:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235657AbiKNDE5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 13 Nov 2022 22:04:57 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 846CF140DF; Sun, 13 Nov 2022 19:04:55 -0800 (PST) Received: from dggpeml500026.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N9Z0f2f8RzmVxc; Mon, 14 Nov 2022 11:04:34 +0800 (CST) Received: from dggpeml500006.china.huawei.com (7.185.36.76) by dggpeml500026.china.huawei.com (7.185.36.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 14 Nov 2022 11:04:53 +0800 Received: from localhost.localdomain (10.175.112.70) by dggpeml500006.china.huawei.com (7.185.36.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 14 Nov 2022 11:04:53 +0800 From: Zhang Changzhong <zhangchangzhong@huawei.com> To: Vincent Mailhol <mailhol.vincent@wanadoo.fr>, Wolfgang Grandegger <wg@grandegger.com>, Marc Kleine-Budde <mkl@pengutronix.de>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, "Jakub Kicinski" <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, "Arunachalam Santhanam" <arunachalam.santhanam@in.bosch.com> CC: Zhang Changzhong <zhangchangzhong@huawei.com>, <linux-can@vger.kernel.org>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH] can: etas_es58x: free netdev when register_candev() failed in es58x_init_netdev() Date: Mon, 14 Nov 2022 11:25:05 +0800 Message-ID: <1668396306-47940-1-git-send-email-zhangchangzhong@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.112.70] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500006.china.huawei.com (7.185.36.76) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749439687587947023?= X-GMAIL-MSGID: =?utf-8?q?1749439687587947023?= |
Series |
can: etas_es58x: free netdev when register_candev() failed in es58x_init_netdev()
|
|
Commit Message
Zhang Changzhong
Nov. 14, 2022, 3:25 a.m. UTC
In case of register_candev() fails, clear es58x_dev->netdev[channel_idx]
and add free_candev(). Otherwise es58x_free_netdevs() will unregister
the netdev that has never been registered.
Fixes: 1dfb6005a60b ("can: etas_es58x: add support for ETAS ES581.4 CAN USB interface")
Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
---
drivers/net/can/usb/etas_es58x/es58x_core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Comments
Hi Zhang, Thank you for the patch. On Mon. 14 nov. 2022 at 12:13, Zhang Changzhong <zhangchangzhong@huawei.com> wrote: > In case of register_candev() fails, clear es58x_dev->netdev[channel_idx] > and add free_candev(). Otherwise es58x_free_netdevs() will unregister > the netdev that has never been registered. > > Fixes: 1dfb6005a60b ("can: etas_es58x: add support for ETAS ES581.4 CAN USB interface") Nitpick, the correct fix tag is: Fixes: 8537257874e9 ("can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces") Aside of that, Acked-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> > Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com> > --- > drivers/net/can/usb/etas_es58x/es58x_core.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c > index 25f863b..ddb7c57 100644 > --- a/drivers/net/can/usb/etas_es58x/es58x_core.c > +++ b/drivers/net/can/usb/etas_es58x/es58x_core.c > @@ -2091,8 +2091,11 @@ static int es58x_init_netdev(struct es58x_device *es58x_dev, int channel_idx) > netdev->dev_port = channel_idx; > > ret = register_candev(netdev); > - if (ret) > + if (ret) { > + es58x_dev->netdev[channel_idx] = NULL; > + free_candev(netdev); > return ret; > + } > > netdev_queue_set_dql_min_limit(netdev_get_tx_queue(netdev, 0), > es58x_dev->param->dql_min_limit); > -- > 2.9.5 >
diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c index 25f863b..ddb7c57 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_core.c +++ b/drivers/net/can/usb/etas_es58x/es58x_core.c @@ -2091,8 +2091,11 @@ static int es58x_init_netdev(struct es58x_device *es58x_dev, int channel_idx) netdev->dev_port = channel_idx; ret = register_candev(netdev); - if (ret) + if (ret) { + es58x_dev->netdev[channel_idx] = NULL; + free_candev(netdev); return ret; + } netdev_queue_set_dql_min_limit(netdev_get_tx_queue(netdev, 0), es58x_dev->param->dql_min_limit);