From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 983671E98ED; Thu, 17 Apr 2025 18:19:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744913940; cv=none; b=DrdveDmcSo7V9ntmfabM+DAd4WuXl97UAjMmNpbCmQD8lCQULjQXCnjK9tvzUi7ak5RfTQKVgL7Z3qvdYqZHFC1aE7GuIsTP9RgOaQxSN/gpYfDz+ZxFrfffw8jWHsHG/XkO556rneep5VgPSTJpigYjrEryS5rgCCzwbgCETAA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744913940; c=relaxed/simple; bh=ZZZF6nKXsH9kVEhGskQ72CuYfvXBmqZdX+GjwCqdaM8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=um3rSAvryKvVsUPo39Gbgr4dnpTTgq571/Y/9K7urrZVH2VuCyFBltRhmzHe6SZvWtBq9g7LnGc46R4qhcf1V7ch9xuaK2161gBcPHIMNHaY8FO/Lw2VhF+T3pd+sFEN3ySr5TvRqkRwgY+YKksDcyRzuIdcdUhjmBYR949rFuE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0pFXlFnW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="0pFXlFnW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E263EC4CEE4; Thu, 17 Apr 2025 18:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744913940; bh=ZZZF6nKXsH9kVEhGskQ72CuYfvXBmqZdX+GjwCqdaM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0pFXlFnWcM1BB4Yv6ThCfpyrJnJvrVlyjeXzxakwSNL341pQ5xVmJFQ7LoexgbSYy NraAw09Tr2VFtbvj4Q95otHTEjThkr0GxlKywcLwGvKxArwEVzjcde61Vq8yRCl3S7 ugAOl38T+nhwe+RUik3bLaWiPm7ZVCsiPtGWbapU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Philipp Stanner , Thomas Zimmermann , Maxime Ripard , Sasha Levin Subject: [PATCH 6.13 022/414] drm/tests: cmdline: Fix drm_display_mode memory leak Date: Thu, 17 Apr 2025 19:46:20 +0200 Message-ID: <20250417175112.305008471@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175111.386381660@linuxfoundation.org> References: <20250417175111.386381660@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.13-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maxime Ripard [ Upstream commit 70f29ca3117a8796cd6bde7612a3ded96d0f2dde ] drm_analog_tv_mode() and its variants return a drm_display_mode that needs to be destroyed later one. The drm_test_cmdline_tv_options() test never does however, which leads to a memory leak. Let's make sure it's freed. Reported-by: Philipp Stanner Closes: https://lore.kernel.org/dri-devel/a7655158a6367ac46194d57f4b7433ef0772a73e.camel@mailbox.org/ Fixes: e691c9992ae1 ("drm/modes: Introduce the tv_mode property as a command-line option") Reviewed-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250408-drm-kunit-drm-display-mode-memleak-v1-4-996305a2e75a@kernel.org Signed-off-by: Maxime Ripard Signed-off-by: Sasha Levin --- drivers/gpu/drm/tests/drm_cmdline_parser_test.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tests/drm_cmdline_parser_test.c b/drivers/gpu/drm/tests/drm_cmdline_parser_test.c index 59c8408c453c2..1cfcb597b088b 100644 --- a/drivers/gpu/drm/tests/drm_cmdline_parser_test.c +++ b/drivers/gpu/drm/tests/drm_cmdline_parser_test.c @@ -7,6 +7,7 @@ #include #include +#include #include static const struct drm_connector no_connector = {}; @@ -955,8 +956,15 @@ struct drm_cmdline_tv_option_test { static void drm_test_cmdline_tv_options(struct kunit *test) { const struct drm_cmdline_tv_option_test *params = test->param_value; - const struct drm_display_mode *expected_mode = params->mode_fn(NULL); + struct drm_display_mode *expected_mode; struct drm_cmdline_mode mode = { }; + int ret; + + expected_mode = params->mode_fn(NULL); + KUNIT_ASSERT_NOT_NULL(test, expected_mode); + + ret = drm_kunit_add_mode_destroy_action(test, expected_mode); + KUNIT_ASSERT_EQ(test, ret, 0); KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(params->cmdline, &no_connector, &mode)); -- 2.39.5