From patchwork Mon Nov 14 08:14:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Changzhong X-Patchwork-Id: 19577 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2024310wru; Mon, 14 Nov 2022 00:05:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf7XtDxIEhMlUiVLEYDuwoyXiMFPsBA9nIosxRg8b2MhSxcOrjXCUwfwGfM2qqenPa1bZopv X-Received: by 2002:a17:907:7854:b0:78b:5182:7ffa with SMTP id lb20-20020a170907785400b0078b51827ffamr9233374ejc.244.1668413105327; Mon, 14 Nov 2022 00:05:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668413105; cv=none; d=google.com; s=arc-20160816; b=T7GqqrNDq0z1zgLTJUyOMMOd9bT6YWVRRBHoBzBRxLaQ8wT9kZacuK/ACWG7MeUePD dHabXceXndtDRUH0GQGUD5oKf5DqjlgbqPyvdS0QZEKJeUhiiXiIxsBO3W1r7ka22g7u /e7XOjVwZEi/cl26iToG4Jw6oAMOPbWq7QSZYJeiF6C/RuaeYYChAjb0jjtv/j02paPA B7eJbFDXWZWIeTto5ARKM6HH/PKAt9wlSp0eGAYoDjMA+KgXMSz5P17pvCCINbfpvpo7 CxMcSjCq+2kfZ1Y0uXvKL+37iw4ugovKlxoViNOZW8QngsG7hUq7P3KE46yJpWS+aLkW 6Kxw== 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=MtskKf/o8qtF1hWn0mJoJNLcx6OAc72PgTMWTDTeFd8=; b=WBONBsSp3NM/Z/Re5eLKfDoIFJ3qCusYdNPQoqvzs8ZcJCTCdkIRTBfQfyFpkJtX0F 5BcBCYZI3l5u0FSP19/l0Sijx2Rk0hGhMeb29OKQw3kNLsRd/KZ3qJf2nx5wLs/HlMSU z5ifPZx0AaTFWguLhTjfios6PEuKTqBHGtGzdLXk6A6qq8Z+oKqk2ojxwGTKBP59Rgi6 S5Zyl7sJkqJ9CAKRe4AdGoF8/msFr3M3+YkklCLYnaU2Jz4Lu0jP/N2JsnR8DgVr0eNt 2WjYo8EL6s+SkYux+XqgB5ygi5U4kWj0RbpIc6XC/fcPfq45AZassNAIvkteJh6m3sB6 YRdA== 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 cr16-20020a170906d55000b0078def5c29e6si6485418ejc.531.2022.11.14.00.04.41; Mon, 14 Nov 2022 00:05:05 -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 S236021AbiKNHzX (ORCPT + 99 others); Mon, 14 Nov 2022 02:55:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236133AbiKNHzG (ORCPT ); Mon, 14 Nov 2022 02:55:06 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9716495AA; Sun, 13 Nov 2022 23:54:31 -0800 (PST) Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N9hQp1tCczmVxH; Mon, 14 Nov 2022 15:54:10 +0800 (CST) Received: from dggpeml500006.china.huawei.com (7.185.36.76) by dggpeml500022.china.huawei.com (7.185.36.66) 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 15:54:29 +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 15:54:29 +0800 From: Zhang Changzhong To: Vincent Mailhol , Wolfgang Grandegger , Marc Kleine-Budde , "David S. Miller" , Eric Dumazet , "Jakub Kicinski" , Paolo Abeni , "Arunachalam Santhanam" CC: Zhang Changzhong , , , Subject: [PATCH v2] can: etas_es58x: free netdev when register_candev() failed in es58x_init_netdev() Date: Mon, 14 Nov 2022 16:14:44 +0800 Message-ID: <1668413685-23354-1-git-send-email-zhangchangzhong@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.175.112.70] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749457940441130885?= X-GMAIL-MSGID: =?utf-8?q?1749457940441130885?= 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: 8537257874e9 ("can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces") Signed-off-by: Zhang Changzhong Signed-off-by: Zhang Changzhong Acked-by: --- v1 -> v2: change to the correct 'Fixes' tag according to Vincent Mailhol 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);