From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D695C4708E for ; Wed, 28 Dec 2022 15:56:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234183AbiL1P4z (ORCPT ); Wed, 28 Dec 2022 10:56:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233544AbiL1P4y (ORCPT ); Wed, 28 Dec 2022 10:56:54 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 903DB17E06 for ; Wed, 28 Dec 2022 07:56:53 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2E102613E9 for ; Wed, 28 Dec 2022 15:56:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44602C433D2; Wed, 28 Dec 2022 15:56:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672243012; bh=HeK+KAzK0BSEobLSQIr/eliNCLZbKEyHKi+Wbe7wzxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vzfpGcgD68fAmxEziUecmjGUIlqxg3K7ub2ot9RJf9tk/k/BRfEIrl3MuIa3cSM0b QUKALxgaGNp1eMb8psylXhA6jswtSGbRmtz1g9W5J1cRVTQYo0VCRDFM2jFonTBHeF 5MqUGL1Jj0phcQqPEhlTd/8hbYlfFc973HDYeUuk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xia Fukun , Jani Nikula , Rodrigo Vivi , Sasha Levin Subject: [PATCH 6.1 0440/1146] drm/i915/bios: fix a memory leak in generate_lfp_data_ptrs Date: Wed, 28 Dec 2022 15:32:59 +0100 Message-Id: <20221228144342.132258884@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228144330.180012208@linuxfoundation.org> References: <20221228144330.180012208@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Xia Fukun [ Upstream commit 1382901f75a5a7dc8eac05059fd0c7816def4eae ] When (size != 0 || ptrs->lvds_ entries != 3), the program tries to free() the ptrs. However, the ptrs is not created by calling kzmalloc(), but is obtained by pointer offset operation. This may lead to memory leaks or undefined behavior. Fix this by replacing the arguments of kfree() with ptrs_block. Fixes: a87d0a847607 ("drm/i915/bios: Generate LFP data table pointers if the VBT lacks them") Signed-off-by: Xia Fukun Signed-off-by: Jani Nikula Link: https://patchwork.freedesktop.org/patch/msgid/20221125063428.69486-1-xiafukun@huawei.com (cherry picked from commit 7674cd0b7d28b952151c3df26bbfa7e07eb2b4ec) Signed-off-by: Rodrigo Vivi Signed-off-by: Sasha Levin --- drivers/gpu/drm/i915/display/intel_bios.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c index 28bdb936cd1f..edbdb949b6ce 100644 --- a/drivers/gpu/drm/i915/display/intel_bios.c +++ b/drivers/gpu/drm/i915/display/intel_bios.c @@ -414,7 +414,7 @@ static void *generate_lfp_data_ptrs(struct drm_i915_private *i915, ptrs->lvds_entries++; if (size != 0 || ptrs->lvds_entries != 3) { - kfree(ptrs); + kfree(ptrs_block); return NULL; } -- 2.35.1