Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4205402pxf; Tue, 23 Mar 2021 05:34:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywiNowJyRD11WAR0y5obMhwquiXe+/8eayAhvBzdkY7uxRYjOS4hHa/GqVoOjubqI6F7Wl X-Received: by 2002:a17:906:b7d5:: with SMTP id fy21mr4702793ejb.153.1616502888393; Tue, 23 Mar 2021 05:34:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616502888; cv=none; d=google.com; s=arc-20160816; b=J51im10CpuZWmL/WmDg79roGuBJjgwyqY4wmDKyfUPivTseVDsfN2+OxMelcXHfzVR 20YNGGLMTtxbG3VkGsR7MmeF3Rvg8yLzx1DxVYs4Xzp0otziTcxY53inWS2eGf17nKpO e/+qJLWl0QN1p87qgBSt5GouN3RtSI438nRgoKyuPSIOtl+RAA6vS2rPtmb99yC7M3rw +qtr8L5sFWWkESse0G/Elsn8IFAInQvJu58cvvopxq6G+2ZziNvjxG31zeRBX502kxSD W68UHWrHij8W+DF3HUR2wyyuecYjb3f4mZj16sjj0dQ7QyD4IULi3C+SJhGUUjmW14+J 6Lrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=j4TSgA2Q4eYLbWqnToNZzajH7T17L/Kgb/nF9MSj6xY=; b=rSMQTezVui8ytSrl5YnU5htar32g2JKKwokAFsgLpg0oNPQ4z4qhZgXKiFLLcsdlqs fMStLsmpuhqMBUItcy/YrbGaygJabaQSVKNC5dPU2Hkrg4oR3mTM/svJ1y3bLYTQTbft X8gBjVSt8gLkYn4Y8Xttkq7SzMBeB8SuRj1C7GG8IE3UJHP2DwQKCr6WjDk7yY+awJ53 93KzXwx1NjZhkmcgXJXVBlUY2uBuOEAeq2ckklMqVBH62AvQDaVnsncHS/n2eiirVu/C l1pOsQo9WRY+eZ7wa4WT8a6/gcUdxcFF9SCle3iQEEiRT2kH83kn2YOESTgCecy9YmFe UK8g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si12863718edp.405.2021.03.23.05.34.23; Tue, 23 Mar 2021 05:34:48 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230482AbhCWMdK (ORCPT + 99 others); Tue, 23 Mar 2021 08:33:10 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:59026 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230011AbhCWMcy (ORCPT ); Tue, 23 Mar 2021 08:32:54 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lOgDF-0007Om-UZ; Tue, 23 Mar 2021 12:32:46 +0000 From: Colin King To: Sunil Goutham , Linu Cherian , Geetha sowjanya , Jerin Jacob , hariprasad , Subbaraya Sundeep , "David S . Miller" , Jakub Kicinski , Rakesh Babu , netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] octeontx2-af: Fix memory leak of object buf Date: Tue, 23 Mar 2021 12:32:45 +0000 Message-Id: <20210323123245.346491-1-colin.king@canonical.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King Currently the error return path when lfs fails to allocate is not free'ing the memory allocated to buf. Fix this by adding the missing kfree. Addresses-Coverity: ("Resource leak") Fixes: f7884097141b ("octeontx2-af: Formatting debugfs entry rsrc_alloc.") Signed-off-by: Colin Ian King --- drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c index 8ec17ee72b5d..9bf8eaabf9ab 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c @@ -253,8 +253,10 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp, return -ENOSPC; lfs = kzalloc(lf_str_size, GFP_KERNEL); - if (!lfs) + if (!lfs) { + kfree(buf); return -ENOMEM; + } off += scnprintf(&buf[off], buf_size - 1 - off, "%-*s", lf_str_size, "pcifunc"); for (index = 0; index < BLK_COUNT; index++) -- 2.30.2