Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1926353pxa; Sun, 23 Aug 2020 23:01:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVLnn/lugn5Vql7FoRpoxX3it9eHp4l5rGkvQZFFKbab1uUl0osPWglHG0L0+8uU4Gxx+g X-Received: by 2002:a17:906:5a83:: with SMTP id l3mr4312487ejq.14.1598248870860; Sun, 23 Aug 2020 23:01:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598248870; cv=none; d=google.com; s=arc-20160816; b=oZ8ZSWJVz6xKy69XtuXc79SgpF8txEN4P1j3W/kuGxAK5D8J+CA7E645OtlFH/rsq/ 3yqJrvdocA2jUYwCyrp0RzwsrdKramVp0YKKUsYEkSaGL4Es7nD24kOjIj6VY8SRgFbt t7FXeNc2GXHY4PCEITuSj/DYezsnnLh0DvD5eV2pANQJ6sWoVC3JasHdQ+QBk1c+wqAy KFJXQLJLkY5hYT7IflXFraw7JrX0GLUep+45adFyhyJCzpnPNAG2XS09/vuDd0DguLeW nig1MUKv5LBX4J9KnzULsRMTP4wEoAJ64jIpjmnvM7g8Tn33taSkQGLseoH6rJ75kSRt M/rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=8Wn4WA9PgXn+jHRrE2MZQVVs161zWBNQYJqWpHbabqg=; b=oNqha3sNCjW1xK/hSNhmRRtvg9HoXGUtnJzAL/1uidDXH8X4n8crM1uPkQEjeKWCii ZUUdgFejrFdSnpEJIUQ9zEgz/5Bx0uqzDG2AnbTfQZknWKQPXaiUJmZlKoDCes31IPpL X2HjCUzGAjjaRnz8HJh8+9KnuQa0+Zc/jSlMsmAofjJ4YeRpKvGfmqsOpbrwM9eUpdiX s3MKvQ8bnV/YTwpVtGARfgoOA0OnKh1T6LgJo6nVaed3j0dmbRZUIESoEoJCZSto/9ED L1IJgr+UI5ZCsCvzyBOq4BFyV39mVDvigE2um24uwaIGNg+cG7wEVDXFPoqnUXDVfdTZ VnRg== ARC-Authentication-Results: i=1; mx.google.com; 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 pg7si156102ejb.395.2020.08.23.23.00.47; Sun, 23 Aug 2020 23:01:10 -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; 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 S1726765AbgHXF6t (ORCPT + 99 others); Mon, 24 Aug 2020 01:58:49 -0400 Received: from mail.zju.edu.cn ([61.164.42.155]:39022 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725947AbgHXF6s (ORCPT ); Mon, 24 Aug 2020 01:58:48 -0400 Received: from localhost.localdomain (unknown [210.32.144.184]) by mail-app4 (Coremail) with SMTP id cS_KCgA3r3oIV0NfjJlCAQ--.61993S4; Mon, 24 Aug 2020 13:58:35 +0800 (CST) From: Dinghao Liu To: dinghao.liu@zju.edu.cn, kjlu@umn.edu Cc: Florian Fainelli , "David S. Miller" , Jakub Kicinski , bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: systemport: Fix memleak in bcm_sysport_probe Date: Mon, 24 Aug 2020 13:58:31 +0800 Message-Id: <20200824055831.26745-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cS_KCgA3r3oIV0NfjJlCAQ--.61993S4 X-Coremail-Antispam: 1UD129KBjvdXoW7JFW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pD7wAIsi Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 dfed9ade6950..0762d5d1a810 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c @@ -2491,8 +2491,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.17.1