Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9258698pxu; Mon, 28 Dec 2020 10:39:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6ZmVp/aeazZn4tosexyfhgfiOn5MTNO/f45X+w9o3cQS0z5wYruZUUL0DnUdIGjMUyVA4 X-Received: by 2002:a17:907:206a:: with SMTP id qp10mr43523733ejb.432.1609180763660; Mon, 28 Dec 2020 10:39:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609180763; cv=none; d=google.com; s=arc-20160816; b=scWbIgAsRl3BIkx9vUyF/MRxgKO2xy2a7yBd2VIXwiI1ceDvx/4oLUTTfbG1Q4+AM9 m5SnzBz7ORwNC2wKMOUdqI5vOHYEEjlshEUVvV+4L79SL0jTaqcHbriOFdtty+Wg3IQU wykFtCEXQlgSwfnZMea8IfPxZf72s2f2nyy7r4tBKbXiqcnTL2pYrvXs1hYMzfx1agYi ArW4L+b/tWCCeWt8zx0cAMwQoxZl62yxSuwi0XNj+TTlfZTl0t0Gywe7V2Jf4ogH+wdP sjUD+SE/G3NNMaML5aTeo2cloCMejxWHWQKCYnfNLl7jDmFr69WMzsEO6ynXx2lHmKGR AzPg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Jk1sJjKMYXlOgVT01z6yEdYNhF+fcaedJ2MpZ7Ow95w=; b=Xkkc07gq71LHuHQPTdGCfqXjJg6YRk4tJtSNmiFZwvOP0IfdC7HlfAioXkb3IFF7JH QC+DHYr8PuPPYRhmhhgYIWs4B9xL3C6J3Xcn9iEmuU+gzKxhtOxLVyWU6DUGusF0ft5B PLwCParhNDBbNRA9HOAJ4857RuSOQ0Y+WZ06ZA6JZj9riLEpM4bLm7/aNnkNgpzzhRW1 3zmWw3jQPnoWxrZnt6BgmVZrGdDAg58TAsWDJYHTCX29J6cfm60q0fzpDcEbUaOZovJB wYpzlnkvorkSRTSBiqBgEvbR9BHuUDiuvSHJJdEKee8u4H8Jl7cP1PLedtnnfR2M9HlY 1fFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=USAn3K8e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r22si19417369eji.295.2020.12.28.10.39.01; Mon, 28 Dec 2020 10:39:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=USAn3K8e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391188AbgL1NiD (ORCPT + 99 others); Mon, 28 Dec 2020 08:38:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:37994 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389256AbgL1Nhm (ORCPT ); Mon, 28 Dec 2020 08:37:42 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 56DA7205CB; Mon, 28 Dec 2020 13:37:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609162621; bh=+oYEI6wNaeyn24hg6BjHs8COG6wyhia1T/n0EIJ/4No=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=USAn3K8eUB8gwbWgc1gfeKzFoIIS7AUX8Jl6bdN7siGW8pMdoWlMTqM2mU/4UPZrl rldu64+ALKgpOrQ3MKPFhYagF7JbN64c/gCYBW8XC+1XnXm6vkJvEp5DJFqugRg37L LQjq6eQtxJzYgp6YG3urbMuzEV3NRP8djDc8vXUw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Qilong , Kurt Van Dijck , Marc Kleine-Budde , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.4 016/453] can: softing: softing_netdev_open(): fix error handling Date: Mon, 28 Dec 2020 13:44:12 +0100 Message-Id: <20201228124938.033247028@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124937.240114599@linuxfoundation.org> References: <20201228124937.240114599@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Qilong [ Upstream commit 4d1be581ec6b92a338bb7ed23e1381f45ddf336f ] If softing_netdev_open() fails, we should call close_candev() to avoid reference leak. Fixes: 03fd3cf5a179d ("can: add driver for Softing card") Signed-off-by: Zhang Qilong Acked-by: Kurt Van Dijck Link: https://lore.kernel.org/r/20201202151632.1343786-1-zhangqilong3@huawei.com Signed-off-by: Marc Kleine-Budde Link: https://lore.kernel.org/r/20201204133508.742120-2-mkl@pengutronix.de Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/can/softing/softing_main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/softing/softing_main.c b/drivers/net/can/softing/softing_main.c index 8242fb287cbbe..16e3f55efa311 100644 --- a/drivers/net/can/softing/softing_main.c +++ b/drivers/net/can/softing/softing_main.c @@ -382,8 +382,13 @@ static int softing_netdev_open(struct net_device *ndev) /* check or determine and set bittime */ ret = open_candev(ndev); - if (!ret) - ret = softing_startstop(ndev, 1); + if (ret) + return ret; + + ret = softing_startstop(ndev, 1); + if (ret < 0) + close_candev(ndev); + return ret; } -- 2.27.0