Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4132192pxk; Tue, 8 Sep 2020 11:28:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzzoM1r30ZO3gE1PPNiP6sDHgAqdC1+a45t9vvujRdrYoAOyB01HCNtIdwciIcOeVDtrlS X-Received: by 2002:aa7:c154:: with SMTP id r20mr256431edp.337.1599589737524; Tue, 08 Sep 2020 11:28:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599589737; cv=none; d=google.com; s=arc-20160816; b=MVnECy6UyGzAP9ry8FJa3lR0hVK48fIu8i2O6r9Z+TE94foRh6OUex59/PqI2Vicwa h1bKAYWn8DMrlspdjsK0Vn017L4F4AZvFAVUylgf5PmZdVtSOi0FKMhicmzjlVUbi1a7 YPUZMxgtTH5NmhEDbR4zHJMlHkVdc++8xWPvxEY5UvtLxImx7DVimFBoejFegqm50MyP R/nRIhqveyc8LW7rdjUK/J9jUtkGCU9B0GGdTFx6ZxrXJZQ2f2k+GuHTZQ+GHF4KJcn/ gXpcrAvLZV1kzmWn06TJpCB6z7r68HPQ42kPltYvE+pIqPb8D91Ftp29jsDL8AfAUDR4 791w== 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=MLxhC3Qj/3wqUnBzQ5KhNG6zrk03kL1ldX5b7q2vjuo=; b=FrinAnC+icjuc/rhf7dkd3IQJRFEDsgeOlucFHrIVi47ocRJ1RD0dIEd3OlEnIGHPi ObhxoiEwlIFOghR2aw/wHVzVvBh1JRvLl2JsW7laS9e1UUYP4SWVFsNb0QKabmzpKwAy GdzwuGo6kKJVA4AMNZCmevi6rSkg/uAOTaNEAl6tgT7QAhmidSrJrpJ+YzA/pBHSVaqe bnnKKmkEZE6WGj7uY3CZwOryEWVy9oT+6vv+4sQXio2GqOr80hUYug0j6fhTr7X8g6oF Sy/TPPy/fRqKOIz4PnyX2YM+61dGnL1BoEnD7zkZi3V0f1onbM0a9RcirfFtZ3lq17m0 VkNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K4OkjV7s; 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=fail (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 i4si12040315edt.298.2020.09.08.11.28.35; Tue, 08 Sep 2020 11:28:57 -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=K4OkjV7s; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731580AbgIHS1x (ORCPT + 99 others); Tue, 8 Sep 2020 14:27:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:56670 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731417AbgIHQK3 (ORCPT ); Tue, 8 Sep 2020 12:10:29 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 1966B24805; Tue, 8 Sep 2020 15:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579794; bh=gNjhvH4+C+o+6lSMH6s19KO6QdOeaKVYNf7dHoeUAVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K4OkjV7sej7JvZ6RxzRizWRuR8FwkC3R9Bh/AfXNCnJQcWZSO3QaZXyBGU8uhxWsD pxkGKEO98CPMATdi82DrkuJyFnN90VH9/2gnXyYUz0dXqMihnTYkCHuzk5T3qozXBv 6WffAd698uca0jxfH8nGwUu5koLR3W4s8IohmFgA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dinghao Liu , "David S. Miller" , Sasha Levin Subject: [PATCH 5.4 036/129] net: systemport: Fix memleak in bcm_sysport_probe Date: Tue, 8 Sep 2020 17:24:37 +0200 Message-Id: <20200908152231.479089440@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152229.689878733@linuxfoundation.org> References: <20200908152229.689878733@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: Dinghao Liu [ Upstream commit 7ef1fc57301f3cef7201497aa27e89ccb91737fe ] When devm_kcalloc() fails, dev should be freed just like what we've done in the subsequent error paths. Fixes: 7b78be48a8eb6 ("net: systemport: Dynamically allocate number of TX rings") Signed-off-by: Dinghao Liu Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/bcmsysport.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c index 4dfdb5a58025b..71eb8914e620b 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c @@ -2453,8 +2453,10 @@ static int bcm_sysport_probe(struct platform_device *pdev) priv->tx_rings = devm_kcalloc(&pdev->dev, txq, sizeof(struct bcm_sysport_tx_ring), GFP_KERNEL); - if (!priv->tx_rings) - return -ENOMEM; + if (!priv->tx_rings) { + ret = -ENOMEM; + goto err_free_netdev; + } priv->is_lite = params->is_lite; priv->num_rx_desc_words = params->num_rx_desc_words; -- 2.25.1