Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9183069pxu; Mon, 28 Dec 2020 08:39:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxl4CeyXf2xcQnR4XzsRPjipvQTA52jAdmuvbcpDVL7LboCxL6SYclqwMP6QT6Nez6Uoupb X-Received: by 2002:aa7:c151:: with SMTP id r17mr42210941edp.106.1609173556555; Mon, 28 Dec 2020 08:39:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609173556; cv=none; d=google.com; s=arc-20160816; b=l9mtXpnwbxH9LMEvH64jpVg72VvlPJmL/UkbiNCIldA7cSONrWUrc2CplFR7USeSle tD5XRL46vxwH5pQKklV2oA1yuZLdDkqL+MwmpgN1MZGCJDjmO3KaNwUWVSWYZfandOAL ddIb8vM/cYzsY1aBYFpUvEK59si2HkPNLFtbgLP7oCKPC+gaB4MVV98H6IhCFkRMam+e A1tRG2Y2cMJ8rCF303SVeYpRTuV1Kme4W4BWGMDHLDuQZVwLD4C1gQBg8qIOgla1qIGW Tw32L4D+5yQ6jhc/qpYgvECz16TLNzbYFmKaQMzO94F3mYELVlZI+F7rUQCKgFn5PTKd 9QsQ== 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=GD0SsnQScpbE2INvkp0HxHIszkR2pDhjlsL/WCSS6B4=; b=ZZq2uTKQXPNT9Z3ORaH+gfh77TVmmChZgkC4LpB3hVq24iDUyK6iZCwbq0t1oVcRjm rRIoDbz2zubnVPeu0Zf35HMJQ5sNWxB2GhX9ECmeKQNZluMVEw7irws/QYz/r4jeYofq qcJgpdIM2CTByyAqtnFx0cmZES7GaeFmvTV2wRZDfvT5XpJ0rZ7tgqN0Vwkw7PAtM0ob qw6M8KWXzIB7bvVjGPpmQjgYAak6UcYLplNLRCKkraIQGLWtPMWd4SgmcbtCF+lVA4Ih 7m1VaxshkjwcNNTOtt3tcMyT1EzbgME0ST5VS8IxvI2+J1NyEIjr2IibpWEDaRmmaCpf teBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qBm0M87Y; 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 jp24si18894117ejb.371.2020.12.28.08.38.52; Mon, 28 Dec 2020 08:39:16 -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=qBm0M87Y; 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 S1729956AbgL1NCF (ORCPT + 99 others); Mon, 28 Dec 2020 08:02:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:58016 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729837AbgL1NBm (ORCPT ); Mon, 28 Dec 2020 08:01:42 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 828B9208BA; Mon, 28 Dec 2020 13:01:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160462; bh=pgLXocH2vJ9te5HZy5zwbwL6P1bRMwPOKZSh4VVgUUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qBm0M87YcKtMqtQ9cH2L+6hHSMx874BGgihGKRup98JTcI9HQ3siA38OgFP02lNtP fBij6a1w91h4gY+TQ9mqvs7ZsiQ4jYjLYApcqybZdLLp6sZ3N4PhkzqH2jV+MFr6Jn c3qcIWcO32W5corSGyloaR/YIQwUkoRb50SC7QxU= 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.9 029/175] can: softing: softing_netdev_open(): fix error handling Date: Mon, 28 Dec 2020 13:48:02 +0100 Message-Id: <20201228124854.670268352@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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 7621f91a8a209..fd48770ba7920 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