Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4877609pjb; Mon, 27 Jul 2020 07:25:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySWPx6Lqk1pOAHfmWGau+ebck1B8SZSgbs0jY12NdbJARmKUicZCFzTBbue+i9eS0+Y2P1 X-Received: by 2002:a17:906:328d:: with SMTP id 13mr21789159ejw.71.1595859901861; Mon, 27 Jul 2020 07:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595859901; cv=none; d=google.com; s=arc-20160816; b=sOfuZonijMdkShaJ8T1SFXPG8KFihn1gepqBdGEp8zbEM9x1xn+zE7nY6VUBUpQzEs QaQJoo8SFHHXbYGQk72YgApOtc6iwezZUWeQjkVllSDW3R94yquPBfiryMHdPTR5C3vV UT6tm4wwgsUodDWdY/mluZghwC7RrgvXHKVBfElIMwMPI8YTNd22na0ZlvNWqx66baPX XbUit6MtvJGOsixT7NcZAWGHm+6LuHGD1vbhTZyVXTOPsf4k7TOVZYN0fy0CCdJp7sIx xoVqJGB5MO8cnWVFPJYIiyyclXRd+CTupbelSjXmvlvlAM4bB2T4ZRXcV3Xebv913qqh jvuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MH5V87ycYZyI6hDVeMTNVDhMbNG5sM/XX277UK5pumk=; b=QdFvk9Mxb8h6xFYS+SkjTX7vaYcRD71Kc/NoC6O8nDv1ipT7aVwDPFjRKvBIiyb4v9 CAdvRF2L5oESE30pZbyz1u4U/gFCYvw6iokDuXFMgnBkPltbJtruYCGjg/F8oDQquVQ7 xMAJfYHs1snt1nQ7wsjCnVyvoU40sxz0PXZvQgNjoJWJ7lWsQBBEobPdukFre9q8TKiu aNmKWIBgrcWU1r9anM9UfEUmDPNryWPPBCr7eDjrXYT2hRBlucqnHMi7E3h64m7R/AwH YAVYpcgz8JSWVLCAP716dbe7NgR9phBroVckUx85dt1j2Jfnpo25kzngXf8Eie8Cczwq 8mqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YmOqp6wH; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p15si3065916ejx.297.2020.07.27.07.24.39; Mon, 27 Jul 2020 07:25:01 -0700 (PDT) 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=@kernel.org header.s=default header.b=YmOqp6wH; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731689AbgG0OVO (ORCPT + 99 others); Mon, 27 Jul 2020 10:21:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:49758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731681AbgG0OVM (ORCPT ); Mon, 27 Jul 2020 10:21:12 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B76D52075A; Mon, 27 Jul 2020 14:21:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859672; bh=buiKqjqGVgEIOE4MuNGd0Ftg20ivBkjeoj4PHmWWcTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YmOqp6wHKNiCcEOzbqDlHI1Qy6Yymnp1rjDItNR/qFel2XNzcYDhgxKxcTTzGiwhu OW0UE9Q8gdPvnfHPQAJaOm/N+TUVaNJQcqKcrutD/lPk/qpKpv15r7OGZfGRrdB73t A2EDSHUXagkET2f2TMh6j6d4kmeVd7Sjxy7ErocQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Wang Hai , "David S. Miller" , Sasha Levin Subject: [PATCH 5.7 061/179] net: smc91x: Fix possible memory leak in smc_drv_probe() Date: Mon, 27 Jul 2020 16:03:56 +0200 Message-Id: <20200727134935.644201441@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134932.659499757@linuxfoundation.org> References: <20200727134932.659499757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wang Hai [ Upstream commit bca9749b1aa23d964d3ab930938af66dbf887f15 ] If try_toggle_control_gpio() failed in smc_drv_probe(), free_netdev(ndev) should be called to free the ndev created earlier. Otherwise, a memleak will occur. Fixes: 7d2911c43815 ("net: smc91x: Fix gpios for device tree based booting") Reported-by: Hulk Robot Signed-off-by: Wang Hai Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/smsc/smc91x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c index 90410f9d3b1aa..1c4fea9c3ec4c 100644 --- a/drivers/net/ethernet/smsc/smc91x.c +++ b/drivers/net/ethernet/smsc/smc91x.c @@ -2274,7 +2274,7 @@ static int smc_drv_probe(struct platform_device *pdev) ret = try_toggle_control_gpio(&pdev->dev, &lp->power_gpio, "power", 0, 0, 100); if (ret) - return ret; + goto out_free_netdev; /* * Optional reset GPIO configured? Minimum 100 ns reset needed @@ -2283,7 +2283,7 @@ static int smc_drv_probe(struct platform_device *pdev) ret = try_toggle_control_gpio(&pdev->dev, &lp->reset_gpio, "reset", 0, 0, 100); if (ret) - return ret; + goto out_free_netdev; /* * Need to wait for optional EEPROM to load, max 750 us according -- 2.25.1