Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9176864pxu; Mon, 28 Dec 2020 08:29:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzqcBf8hXDLHkzU2ieZIiqVaelIeCk3sY9hjQZmdwGYIvljgsfyVn6TEf1DnQrzTEZ+C3El X-Received: by 2002:a05:6402:254a:: with SMTP id l10mr35890331edb.264.1609172974018; Mon, 28 Dec 2020 08:29:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609172974; cv=none; d=google.com; s=arc-20160816; b=YClW7pMM9td9m6JxaW7fhz0YTWPqAUWJT9SKrRrpZT8/1uqb+sRnlj/y3Mz3P+Ma97 KijzwKiJYbNzEiNTY/tbdHqQqxe1ZFyVZKxkbFtW9+vaoe1l0ZmrQ3y7Ge6eXGKYPrfC OZMXo1iIoLJnbTPX+5ph7kHpgEMxVxYLAiyfefh0fNVDp6VxJFUkRAgpDhqlO9pIzU6p A/ANJsIzhjC77eRMrzU/oMIMsXixRGuOfyVZGr3/1Qv3lR4b7SRzulpmR52a2G34CzCO SSHW+t/AUYEgrJ2+hWva+Zq0e2B59atPMNGGkDBnkgQ56Fj0gXHNefftHvw3AGOs60Bx Heyg== 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=4PiTkjzjcFpvyisfaj6hiuukf/JYQE/foZUhW4N+KAg=; b=Aggu6f/oCYTTZAATzVYkBW34TDV5FY5NpLcSYPSyAbrzwz6q6eMKwi7lsz2hDa6aL9 uu73UiarV4ocb4LSRKzx6TWkZxB3UUSYR6pp3TxoBDUgKra4BecBspW24GxOTmXoUEt+ /wjnkBd+D93Hkfu5dZ61sjWIfcjj9yH3Bzchq0C4x8CovuN62oBE4QzJ84rf0VKqctfY zFHJp3MbhRnGZjRupY84UZAkMIPNWzzVCNN2f5d/xsflvoy4pJ8M0EH6TePUXVOoanTQ v8hK3xcTsRS9F79uCsGKvQFyMK4PCVGQv89OJFfhcjW9/6DMUlKr4mvkKJo8izMQXLNd 5e5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vsLtPLLb; 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 gy15si18381344ejb.752.2020.12.28.08.29.07; Mon, 28 Dec 2020 08:29:34 -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=vsLtPLLb; 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 S1731186AbgL1NJq (ORCPT + 99 others); Mon, 28 Dec 2020 08:09:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:37532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731160AbgL1NJp (ORCPT ); Mon, 28 Dec 2020 08:09:45 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C0E0422B47; Mon, 28 Dec 2020 13:09:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160944; bh=g/4f5Xc7ROlr45Ko0wP8u+ZhDu3oOij8mjHyT7godJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vsLtPLLbpxpupaE2XjN4P9aWAOOKho6MJVZbolVy9wvjqNaeXZeaomrW0Eu3VSFn8 h53sNhsRrVJr2aSKYUkyHM8tQSNEl2DSB892HZnmNixG0WWbSOQGjIY5k55ZmuCsUx en7GXMPzNfiTRxzTquIgIsSfRb8bykRJq9NzeGi0= 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 4.14 040/242] can: softing: softing_netdev_open(): fix error handling Date: Mon, 28 Dec 2020 13:47:25 +0100 Message-Id: <20201228124906.644879306@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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 5f64deec9f6c1..26b3072daabd6 100644 --- a/drivers/net/can/softing/softing_main.c +++ b/drivers/net/can/softing/softing_main.c @@ -393,8 +393,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