From patchwork Tue Sep 8 15:25:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264222 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DEC4C433E2 for ; Tue, 8 Sep 2020 19:01:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37E1820C09 for ; Tue, 8 Sep 2020 19:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599591669; bh=y+zrUYeyGIEDIzii/wZZiVN5+0rnA8OlhzATkZVQEdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=PWg5KZzxTCClUD/ZRO1VRzoRmwNYjRpoBlqcUW1mwy1SeWjGeQIsMJ9ioX3oC+Afk IsjX80qaR91nrCRe7I4gRM/tw/h0Y7I+8wg051Oqq42bIsLJtZrfv4HFCSG88yQZ86 WM+/S5vn7JxmKwlkAzlIhjnNbABi9j74oAo+j8ls= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731375AbgIHTBA (ORCPT ); Tue, 8 Sep 2020 15:01:00 -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 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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;