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 497C9C8EB; Wed, 23 Apr 2025 14:52:38 +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=1745419958; cv=none; b=h0J09Nwfrer6/DUTPdE4m/iilGNAF2RIfyPI8fN7gotOjTeMbyhbscRQW0UNFe4ylld4bLmIEFlEuykr2qgRyTWKahX54ctHYRAM8C29h8e1WtKMgNi6noNixoH6IaJqW2M2A/27tu/+dRpKCJ4x9j0z9Bg1rqB8rBL4K5GCFfo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745419958; c=relaxed/simple; bh=v/3Z50G/ZVoVxB+Yqr79OSo8S82QOLed/8LQz5NHCoI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HBVyEYiB6g96rNRCFB0KdOkXdDl5LBJgeuSu8imgEwAaqoC9SMxuYtmtccYFpbequ7QY5nSzxfTW9dIi4Wy/L1m/+zPga82oB9cnXwSt1/sPjdD32n8yuT8UMgdy7HqX+sRWRiRY4EPHjqAmUsnXaF8NGSlakjQTdu4VzPqr6aY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=K1NGtCvA; 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="K1NGtCvA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D15A1C4CEE2; Wed, 23 Apr 2025 14:52:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745419958; bh=v/3Z50G/ZVoVxB+Yqr79OSo8S82QOLed/8LQz5NHCoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K1NGtCvA0r0qF4MPQKJXECfczWbkw8ri0Ggitft9eXzHtcEUm5S1S44DIPJys0bvN CWaOOrQyFWNUkFI0HL6CIVUFEgZppSK3CvUBfPeZYsqtJl4n1K+i6tbrNdnI3+IGQj Uxu828unvtT8E9NydN14gu7x0MlSIF1Vxo8dsQvE= 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.6 024/393] drm/tests: cmdline: Fix drm_display_mode memory leak Date: Wed, 23 Apr 2025 16:38:40 +0200 Message-ID: <20250423142644.263863381@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250423142643.246005366@linuxfoundation.org> References: <20250423142643.246005366@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-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 88f7f518ffb3b..05dd5cc3b604b 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