From patchwork Mon Dec 16 01:52:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanxin Qi X-Patchwork-Id: 13909369 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5A943E77180 for ; Mon, 16 Dec 2024 08:25:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D05DE10E3F5; Mon, 16 Dec 2024 08:25:53 +0000 (UTC) Received: from mail.nfschina.com (unknown [42.101.60.213]) by gabe.freedesktop.org (Postfix) with SMTP id EA49010E08B; Mon, 16 Dec 2024 01:53:07 +0000 (UTC) Received: from localhost.localdomain (unknown [103.163.180.3]) by mail.nfschina.com (MailData Gateway V2.8.8) with ESMTPSA id B1EE860272AA8; Mon, 16 Dec 2024 09:53:02 +0800 (CST) X-MD-Sfrom: zhanxin@nfschina.com X-MD-SrcIP: 103.163.180.3 From: Zhanxin Qi To: kherbst@redhat.com, lyude@redhat.com, dakr@redhat.com, airlied@gmail.com, simona@ffwll.ch Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, Zhanxin Qi Subject: [PATCH] drm/nouveau: Fix memory leak in nvbios_iccsense_parse Date: Mon, 16 Dec 2024 09:52:46 +0800 Message-Id: <20241216015246.141006-1-zhanxin@nfschina.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 16 Dec 2024 08:25:53 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The nvbios_iccsense_parse function allocates memory for sensor data but fails to free it when the function exits, leading to a memory leak. Add proper cleanup to free the allocated memory. Signed-off-by: Zhanxin Qi --- drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c index 8f0ccd3664eb..502608d575f7 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c @@ -291,6 +291,9 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev) list_add_tail(&rail->head, &iccsense->rails); } } + + kfree(stbl.rail); + return 0; }