Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3426919pxf; Mon, 29 Mar 2021 01:46:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKlAAGpTkXm62L0cWpMfO6SDObXtVhSHLOumM1D4drRFQmnh9k4FwUEraLwDNlqsrp7vcM X-Received: by 2002:a17:906:6817:: with SMTP id k23mr26934479ejr.6.1617007608142; Mon, 29 Mar 2021 01:46:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007608; cv=none; d=google.com; s=arc-20160816; b=WDElQ2UuO5MYF17gWiFCC89KgCS14NaKXXR2nX6ZQU0Cjs7gWkr5cXzKb/TCtVAGWK /IhjvS2SWEBCud2Fu+6Ez94PxMLKOTFvw7FCunKJj45qMOunoRE2Eq7jTOcsCPUhX7hO SuYSCKuTcGlGXOhy8HruzxcJvZQ463mfXIbsthg573qFCH5ZZwZusQ5rDc+8t8LLAUqV D6df7wtF5YG5I/k5VP/9Nh3omFsEj+UqixV9GCfjrJhMmOjnxgacTmOHqkPjUjNZhANr B9S+SiHGFbfIeKPQGBy7H1yyginb+sBzSZRYtem16EOzCWXbbFRnXuKlwh6U/m6P6WNK EIOQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RAOIizt4lIxxub+Uq3wkXgYMDJsmt+fd4sdG7OkMpK4=; b=pbu0BaZL4emZX+JEGLv+eIRb94bSe2soGlJw0mDH68LG9CrhhSfPIBAh9JZgpVbo5S 7N+tJuRqrPRT6hhja3KxmvWsaUnFJA7WkNzfMQX8Hrv7nqqTsIW+8RvdANerdh1MEziz d3B7HJ+B4JsedalJ6OGL2uHtwEZsow3kFW/X0Vb9SrLPZXDrhgHKVioaj3vJrVyQ+o7I Ojr2yhGK2s+seL5KpxAq23GKvldGy7UvxSGT5DmbChaWAKUCJndU/s9zmOTNx44F88xx cwHwtzygEGLqQXhd3owcQkhstrSZsj5kUYxgCSB9J21AXNZx8ioZVfhYVLLVdf7GD+xk Ohzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=y+rnEjJ4; 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=pass (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 hc40si11755178ejc.276.2021.03.29.01.46.25; Mon, 29 Mar 2021 01:46: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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=y+rnEjJ4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233706AbhC2Iow (ORCPT + 99 others); Mon, 29 Mar 2021 04:44:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:41376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233980AbhC2I1i (ORCPT ); Mon, 29 Mar 2021 04:27:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 71FBE619A7; Mon, 29 Mar 2021 08:26:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006384; bh=t+78ARRy+Zp+PWsY434rcxDjEhFah7gtlT0eaFU/Cog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y+rnEjJ4dX+wziQqxIcEDK7CLDLE6Tqb89e8HTvj22vYCkY81RkjA5CX7sNjWf0yx YpooR0rbciU1w40hUWE2bdXyx+FGF+tjz5lISIONG8gUvwV7B4lly+bQttbaagrjWf B1e+XoU8Djsp5Jq3/8kdF2Q1cXqjpygX49tKdRPw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Sunil Goutham , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 176/221] octeontx2-af: Fix memory leak of object buf Date: Mon, 29 Mar 2021 09:58:27 +0200 Message-Id: <20210329075635.021745601@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 9e0a537d06fc36861e4f78d0a7df1fe2b3592714 ] 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 Acked-by: Sunil Goutham Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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 c018121d4cc5..bc870bff14df 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c @@ -163,8 +163,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.1