Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9190620pxu; Mon, 28 Dec 2020 08:51:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFYWO43XuWVpqPFef3hAfYdB+V1Py+DgFZxDkR6btsQJJq3HzVPa/lHoUDl7fy3AUOCUfT X-Received: by 2002:aa7:d906:: with SMTP id a6mr43113890edr.121.1609174306090; Mon, 28 Dec 2020 08:51:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609174306; cv=none; d=google.com; s=arc-20160816; b=CvIBC3aKYXHf/w/rKGZg0kiCuvxTW45L7xDbQytm4VTsE8Zxt7WLAmrA904e0tn2KS 778HpGpouGgxhPyT5TTJ7dpdEWSBTJLn/7whilfgS3NSlsw2Fa8BYEGrcTMA3QkmxRrN 9SrWbm2Ivdccb1sO7Nu0QE+SaRwhd0jN4LAO3JeoHs48bXtnYOf5zwdXIaGR6S9LXdoL 1wP7L++OCcwPFHR3TFLvi5QQqNCK5QfwaNGlMGW7SBjDn7FGndRs+3y4TA2CqiBL3SQk QKchgBSXa8+UD84HrnsKH9c8+ZcJyR//Spzhkuh7oo40NEJ84guyjEqXmQPIifWw/s35 WPDg== 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=a6CTWwRGt9AKgex3QzlHWqnu6lcj1Gri9mXzC4wMBXnTQQfOz3YdAuqRTFqiyHhUCg 4w2cHgTH4JfatC/QpjTx0kIBQrrPPmMWjPn23EahfKAPJxraO+5ZDvOoImtGbXhyGOeA Z7ok3pqRVnjkoxrDdvnI6cvW9gT5phiDiGecZgwXYHcaUIYp6Y2QOulTLgN9EZ3iMG7a AlRGIlHtDR0qEI4gVXW4Hn4clDLSM8hl8IpGzx34bIcea9qDvrJ2uKaGx9ME2jdxuxVB +mhHFNZWyUiKZ1/a1OjY0h48V8+bu+LB7D8hgdWcW4dCmJFKl1fV6XlT9B/k+CAhChOX zcrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UVShaxSC; 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 b24si18454340eje.504.2020.12.28.08.51.23; Mon, 28 Dec 2020 08:51:46 -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=UVShaxSC; 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 S1728195AbgL1Mxe (ORCPT + 99 others); Mon, 28 Dec 2020 07:53:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:50432 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728171AbgL1Mxa (ORCPT ); Mon, 28 Dec 2020 07:53:30 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 653F72245C; Mon, 28 Dec 2020 12:52:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609159947; bh=pgLXocH2vJ9te5HZy5zwbwL6P1bRMwPOKZSh4VVgUUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UVShaxSCn1yw36t3USQNoqSl2GpIqmeWS2LgO+CsJut2EDL6P+/3XiS1MTeujU29m fv4pFmzb1nimyLp5ifEFqV38afr3FbG1ILTURa6AKETk2aBreGFnLWiWQyJdYkvJ4Q mZ4f43IYDVv2sH/eUPV/ocWMaX7vzswsLREDhih8= 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.4 023/132] can: softing: softing_netdev_open(): fix error handling Date: Mon, 28 Dec 2020 13:48:27 +0100 Message-Id: <20201228124847.531480524@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124846.409999325@linuxfoundation.org> References: <20201228124846.409999325@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