Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4153050pxk; Tue, 8 Sep 2020 12:02:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHHaXMPqHS3dDnZoneBzvCyyG/8tutBT64HEsTswf9pO7cEX4lAB2+d/XGNkALp08UriX2 X-Received: by 2002:a17:907:9ed:: with SMTP id ce13mr26487883ejc.180.1599591769985; Tue, 08 Sep 2020 12:02:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599591769; cv=none; d=google.com; s=arc-20160816; b=mAq/2IZ0DVd4ta+Kqxr2IwLQL5+QCtyOQhkjFRq96ag/UwCrgP9d+ae7UTQRtQAF+j cmmnshCx0ywmvG2Cxmqk4hqRSE9dT3O7sA7xenp0rdhflNOiqfbW72x8web1w9nd7UcA OdwjAJrmDIfO+zuF8JagAZUsw/bUKvK7soMfhYltw4mdvOeKQ/6iOwiIn+JDn+tdHp7n s0K8bOZl/Qn35y3F7Vg8gqsmznRL40k2f+vsJFJf/JrMB2F17ZJNVG9V63N4n/LE3zBw PSuqv+3uaC3iNlqqxQ+EEV0F+NYeDGFjlE+dMBugn4Gt3NNAeLf0O4uZYmSwd7oGGFj1 xEVA== 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=jsuRb3RhTnHApUu1k1qfy4kGIMUpwwDGJyz8/q7WEs4=; b=oEJ4m/+otkWKFHHAdeVWpevo+dzmLppkYXP9xGkhF9Den4YgJG9zwTI8HU4rFStW0G V2fNtw9z1ELPtBQ/+OCXozIMZQzQRALI+zvWef4tFLE+icyg629fV7emnMCpny+iIikb wUzuaYwULp+E3ks1SSgXnwDb91TpNAizlH4JlW0TTo1+jVeLh5Uhc8rcL8qoyOjrOfr9 hSmUgZK5HcVO1bDQHqjj/IkFFZjYf7UOMSmiIY/gZi1A81EU6rFgBLn3R+sTfIwYRJvi IGeDwYADv/DpPjamK9sZ0srmvc221kZRf6bCB3WMLYyf5wkhalRaP/ZE2qK5vLTr/Ivc OFWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=N7oxB6aJ; 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 f6si9830904edm.308.2020.09.08.12.02.27; Tue, 08 Sep 2020 12:02:49 -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=N7oxB6aJ; 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 S1731501AbgIHTBP (ORCPT + 99 others); Tue, 8 Sep 2020 15:01:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:53446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731295AbgIHQIC (ORCPT ); Tue, 8 Sep 2020 12:08:02 -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 2F36F23F2C; Tue, 8 Sep 2020 15:48:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599580086; bh=y+zrUYeyGIEDIzii/wZZiVN5+0rnA8OlhzATkZVQEdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N7oxB6aJDGKFNQiZrVoFFOHSG1OnXSZY4D7DfQy5iSAwkosEhdrqK+9yQ+P9g4QCC qFCfT6N5I6qlZPAVcNUNEQICuJzAeiCsgyKjV38QPaU0NwWSGJYpKHNG+SKJkg5U1H i3opgvgNf5b2HMwEuAZaO+WSElBUEogpQTZTi0Ow= 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 4.19 26/88] net: systemport: Fix memleak in bcm_sysport_probe Date: Tue, 8 Sep 2020 17:25:27 +0200 Message-Id: <20200908152222.372361279@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152221.082184905@linuxfoundation.org> References: <20200908152221.082184905@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 6b761f6b8fd56..9a614c5cdfa22 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c @@ -2441,8 +2441,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