linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] drm: Fix potential null pointer dereference issues in drm_managed.c
@ 2025-07-03  9:28 Haoxiang Li
  2025-07-16  2:34 ` kernel test robot
  2025-08-03 22:51 ` Dmitry Baryshkov
  0 siblings, 2 replies; 3+ messages in thread
From: Haoxiang Li @ 2025-07-03  9:28 UTC (permalink / raw)
  To: maarten.lankhorst, mripard, tzimmermann, airlied, simona, sam
  Cc: dri-devel, linux-kernel, Haoxiang Li, stable

Add check for the return value of kstrdup_const() in drm_managed.c
to prevent potential null pointer dereference.

Fixes: c6603c740e0e ("drm: add managed resources tied to drm_device")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
 drivers/gpu/drm/drm_managed.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/drm_managed.c b/drivers/gpu/drm/drm_managed.c
index cc4c463daae7..368763d4c24e 100644
--- a/drivers/gpu/drm/drm_managed.c
+++ b/drivers/gpu/drm/drm_managed.c
@@ -151,6 +151,11 @@ int __drmm_add_action(struct drm_device *dev,
 	}
 
 	dr->node.name = kstrdup_const(name, GFP_KERNEL);
+	if (!dr->node.name) {
+		kfree(dr);
+		return -ENOMEM;
+	}
+
 	if (data) {
 		void_ptr = (void **)&dr->data;
 		*void_ptr = data;
@@ -236,6 +241,10 @@ void *drmm_kmalloc(struct drm_device *dev, size_t size, gfp_t gfp)
 		return NULL;
 	}
 	dr->node.name = kstrdup_const("kmalloc", gfp);
+	if (dr->node.name) {
+		kfree(dr);
+		return NULL;
+	}
 
 	add_dr(dev, dr);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH RESEND] drm: Fix potential null pointer dereference issues in drm_managed.c
  2025-07-03  9:28 [PATCH RESEND] drm: Fix potential null pointer dereference issues in drm_managed.c Haoxiang Li
@ 2025-07-16  2:34 ` kernel test robot
  2025-08-03 22:51 ` Dmitry Baryshkov
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2025-07-16  2:34 UTC (permalink / raw)
  To: Haoxiang Li
  Cc: oe-lkp, lkp, dri-devel, maarten.lankhorst, mripard, tzimmermann,
	airlied, simona, sam, linux-kernel, Haoxiang Li, stable,
	oliver.sang



Hello,

kernel test robot noticed "kunit.drm_test_framebuffer_create.ABGR8888_pitch_less_than_min_required.fail" on:

commit: e33530ce8ac50d5155aa7a83f6dcd8b8372279d0 ("[PATCH RESEND] drm: Fix potential null pointer dereference issues in drm_managed.c")
url: https://github.com/intel-lab-lkp/linux/commits/Haoxiang-Li/drm-Fix-potential-null-pointer-dereference-issues-in-drm_managed-c/20250703-173209
base: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git b4911fb0b060899e4eebca0151eb56deb86921ec
patch link: https://lore.kernel.org/all/20250703092819.2535786-1-haoxiang_li2024@163.com/
patch subject: [PATCH RESEND] drm: Fix potential null pointer dereference issues in drm_managed.c

in testcase: kunit
version: 
with following parameters:

	group: group-00



config: x86_64-rhel-9.4-kunit
compiler: gcc-12
test machine: 8 threads 1 sockets Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz (Haswell) with 16G memory

(please refer to attached dmesg/kmsg for entire log/backtrace)


besides, more issues are observed

b4911fb0b060899e e33530ce8ac50d5155aa7a83f6d
---------------- ---------------------------
       fail:runs  %reproduction    fail:runs
           |             |             |
           :6          100%           6:6     kunit.drm_test_fb_build_fourcc_list.XRGB8888_as_native_format.fail
           :6          100%           6:6     kunit.drm_test_fb_build_fourcc_list.convert_alpha_formats.fail
           :6          100%           6:6     kunit.drm_test_fb_build_fourcc_list.fail
           :6          100%           6:6     kunit.drm_test_fb_build_fourcc_list.no_native_formats.fail
           :6          100%           6:6     kunit.drm_test_fb_build_fourcc_list.random_formats.fail
           :6          100%           6:6     kunit.drm_test_fb_build_fourcc_list.remove_duplicates.fail
           :6          100%           6:6     kunit.drm_test_fb_memcpy.drm_format_helper_test.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_check_src_coords.Fail_overflowing_fb_with_source_height.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_check_src_coords.Fail_overflowing_fb_with_source_width.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_check_src_coords.Fail_overflowing_fb_with_x-axis_coordinate.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_check_src_coords.Fail_overflowing_fb_with_y-axis_coordinate.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_check_src_coords.Success_source_fits_into_fb.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_check_src_coords.drm_test_framebuffer_cleanup.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_check_src_coords.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_Buffer_offset_for_inexistent_plane.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_Extra_pitches_with_DRM_MODE_FB_MODIFIERS.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_Extra_pitches_without_DRM_MODE_FB_MODIFIERS.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_Height_0.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_Invalid_buffer_handle.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_Invalid_buffer_modifier_DRM_FORMAT_MOD_SAMSUNG_64_32_TILE.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_Invalid_flag.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_Invalid_width.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_Large_buffer_offset.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_Out_of_bound_height_*_pitch_combination.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_Set_DRM_MODE_FB_MODIFIERS_without_modifiers.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_Valid_buffer_modifier.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_Width_0.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_max_sizes.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_normal_sizes.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_pitch_greater_than_min_required.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.ABGR8888_pitch_less_than_min_required.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.NV12_Handle_for_inexistent_plane.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.NV12_Handle_for_inexistent_plane_without_DRM_MODE_FB_MODIFIERS.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.NV12_Invalid_modifier/missing_DRM_MODE_FB_MODIFIERS_flag.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.NV12_Invalid_pitch.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.NV12_Max_sizes.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.NV12_Modifier_for_inexistent_plane.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.NV12_Normal_sizes.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.NV12_Valid_modifiers_without_DRM_MODE_FB_MODIFIERS.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.NV12_different_modifier_per-plane.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.NV12_with_DRM_FORMAT_MOD_SAMSUNG_64_32_TILE.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.No_pixel_format.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.X0L2_Handle_for_inexistent_plane.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.X0L2_Invalid_pitch.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.X0L2_Max_sizes.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.X0L2_Modifier_for_inexistent_plane.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.X0L2_Modifier_without_DRM_MODE_FB_MODIFIERS_set.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.X0L2_Normal_sizes.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.X0L2_Offset_for_inexistent_plane_without_DRM_MODE_FB_MODIFIERS_set.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.X0L2_Pitch_greater_than_minimum_required.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.X0L2_Valid_modifier.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.YUV420_10BIT_Invalid_modifier_DRM_FORMAT_MOD_LINEAR.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.YVU420_DRM_MODE_FB_MODIFIERS_set_without_modifier.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.YVU420_Different_buffer_offsets/pitches.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.YVU420_Different_modifiers_per_plane.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.YVU420_Different_pitches.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.YVU420_Invalid_pitch.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.YVU420_Max_sizes.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.YVU420_Modifier_for_inexistent_plane.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.YVU420_Modifier_set_just_for_plane_0_1_with_DRM_MODE_FB_MODIFIERS.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.YVU420_Modifier_set_just_for_plane_0_without_DRM_MODE_FB_MODIFIERS.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.YVU420_Modifier_set_just_for_planes_0_1_without_DRM_MODE_FB_MODIFIERS.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.YVU420_Normal_sizes.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.YVU420_Valid_modifier.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.drm_framebuffer.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.drm_test_framebuffer_free.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.drm_test_framebuffer_init.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.drm_test_framebuffer_init_bad_format.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.drm_test_framebuffer_init_dev_mismatch.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.drm_test_framebuffer_lookup.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.drm_test_framebuffer_lookup_inexistent.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.drm_test_framebuffer_modifiers_not_supported.fail
           :6          100%           6:6     kunit.drm_test_framebuffer_create.fail


If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <oliver.sang@intel.com>
| Closes: https://lore.kernel.org/oe-lkp/202507160354.21a14db0-lkp@intel.com


(part of full log)

[  137.733532]         KTAP version 1
[  137.743385]         # Subtest: drm_test_framebuffer_create
[  137.744157]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  137.767882]         not ok 1 ABGR8888 normal sizes
[  137.768882]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  137.791777]         not ok 2 ABGR8888 max sizes
[  137.792684]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  137.815217]         not ok 3 ABGR8888 pitch greater than min required
[  137.816102]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  137.840600]         not ok 4 ABGR8888 pitch less than min required
[  137.841336]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  137.865608]         not ok 5 ABGR8888 Invalid width
[  137.866324]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  137.889284]         not ok 6 ABGR8888 Invalid buffer handle
[  137.890013]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  137.913751]         not ok 7 No pixel format
[  137.914407]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  137.936719]         not ok 8 ABGR8888 Width 0
[  137.937549]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  137.960134]         not ok 9 ABGR8888 Height 0
[  137.961342]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  137.983942]         not ok 10 ABGR8888 Out of bound height * pitch combination
[  137.984877]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.010085]         not ok 11 ABGR8888 Large buffer offset
[  138.010805]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.034402]         not ok 12 ABGR8888 Buffer offset for inexistent plane
[  138.035121]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.060049]         not ok 13 ABGR8888 Invalid flag
[  138.061100]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.084131]         not ok 14 ABGR8888 Set DRM_MODE_FB_MODIFIERS without modifiers
[  138.084993]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.110649]         not ok 15 ABGR8888 Valid buffer modifier
[  138.111393]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.135217]         not ok 16 ABGR8888 Invalid buffer modifier(DRM_FORMAT_MOD_SAMSUNG_64_32_TILE)
[  138.135933]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.162947]         not ok 17 ABGR8888 Extra pitches without DRM_MODE_FB_MODIFIERS
[  138.163630]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.189522]         not ok 18 ABGR8888 Extra pitches with DRM_MODE_FB_MODIFIERS
[  138.190235]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.215622]         not ok 19 NV12 Normal sizes
[  138.216403]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.239195]         not ok 20 NV12 Max sizes
[  138.240023]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.262575]         not ok 21 NV12 Invalid pitch
[  138.263258]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.286058]         not ok 22 NV12 Invalid modifier/missing DRM_MODE_FB_MODIFIERS flag
[  138.287019]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.313103]         not ok 23 NV12 different  modifier per-plane
[  138.313926]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.337915]         not ok 24 NV12 with DRM_FORMAT_MOD_SAMSUNG_64_32_TILE
[  138.339024]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.363845]         not ok 25 NV12 Valid modifiers without DRM_MODE_FB_MODIFIERS
[  138.364927]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.390321]         not ok 26 NV12 Modifier for inexistent plane
[  138.390992]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.415040]         not ok 27 NV12 Handle for inexistent plane
[  138.415717]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.439640]         not ok 28 NV12 Handle for inexistent plane without DRM_MODE_FB_MODIFIERS
[  138.440361]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.467024]         not ok 29 YVU420 DRM_MODE_FB_MODIFIERS set without modifier
[  138.467691]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.493216]         not ok 30 YVU420 Normal sizes
[  138.494137]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.516948]         not ok 31 YVU420 Max sizes
[  138.517886]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.540344]         not ok 32 YVU420 Invalid pitch
[  138.541003]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.563878]         not ok 33 YVU420 Different pitches
[  138.564688]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.587901]         not ok 34 YVU420 Different buffer offsets/pitches
[  138.589052]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.613521]         not ok 35 YVU420 Modifier set just for plane 0, without DRM_MODE_FB_MODIFIERS
[  138.614198]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.641089]         not ok 36 YVU420 Modifier set just for planes 0, 1, without DRM_MODE_FB_MODIFIERS
[  138.642154]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.669373]         not ok 37 YVU420 Modifier set just for plane 0, 1, with DRM_MODE_FB_MODIFIERS
[  138.670279]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.697162]         not ok 38 YVU420 Valid modifier
[  138.697838]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.720852]         not ok 39 YVU420 Different modifiers per plane
[  138.721447]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.746307]         not ok 40 YVU420 Modifier for inexistent plane
[  138.747165]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.771457]         not ok 41 YUV420_10BIT Invalid modifier(DRM_FORMAT_MOD_LINEAR)
[  138.772098]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.798108]         not ok 42 X0L2 Normal sizes
[  138.798677]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.821384]         not ok 43 X0L2 Max sizes
[  138.822002]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.844273]         not ok 44 X0L2 Invalid pitch
[  138.844919]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.867733]         not ok 45 X0L2 Pitch greater than minimum required
[  138.868358]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.893003]         not ok 46 X0L2 Handle for inexistent plane
[  138.893837]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.917784]         not ok 47 X0L2 Offset for inexistent plane, without DRM_MODE_FB_MODIFIERS set
[  138.918775]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.945711]         not ok 48 X0L2 Modifier without DRM_MODE_FB_MODIFIERS set
[  138.946324]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.971458]         not ok 49 X0L2 Valid modifier
[  138.972065]     # drm_test_framebuffer_create: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  138.995030]         not ok 50 X0L2 Modifier for inexistent plane
[  138.995048]     # drm_test_framebuffer_create: pass:0 fail:50 skip:0 total:50
[  139.001755]     not ok 3 drm_test_framebuffer_create
[  139.010357]     # drm_test_framebuffer_free: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  139.033318]     not ok 4 drm_test_framebuffer_free
[  139.034199]     # drm_test_framebuffer_init: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  139.056932]     not ok 5 drm_test_framebuffer_init
[  139.057721]     # drm_test_framebuffer_init_bad_format: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  139.081362]     not ok 6 drm_test_framebuffer_init_bad_format
[  139.082208]     # drm_test_framebuffer_init_dev_mismatch: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  139.107079]     not ok 7 drm_test_framebuffer_init_dev_mismatch
[  139.108058]     # drm_test_framebuffer_lookup: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  139.132003]     not ok 8 drm_test_framebuffer_lookup
[  139.133189]     # drm_test_framebuffer_lookup_inexistent: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  139.157294]     not ok 9 drm_test_framebuffer_lookup_inexistent
[  139.158145]     # drm_test_framebuffer_modifiers_not_supported: ASSERTION FAILED at drivers/gpu/drm/tests/drm_framebuffer_test.c:389
                   Expected priv is not error, but is: -12
[  139.183665]     not ok 10 drm_test_framebuffer_modifiers_not_supported
[  139.183680] # drm_framebuffer: pass:0 fail:10 skip:0 total:10
[  139.190902] # Totals: pass:0 fail:63 skip:0 total:63
[  139.197336] not ok 1 drm_framebuffer



The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20250716/202507160354.21a14db0-lkp@intel.com



-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH RESEND] drm: Fix potential null pointer dereference issues in drm_managed.c
  2025-07-03  9:28 [PATCH RESEND] drm: Fix potential null pointer dereference issues in drm_managed.c Haoxiang Li
  2025-07-16  2:34 ` kernel test robot
@ 2025-08-03 22:51 ` Dmitry Baryshkov
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Baryshkov @ 2025-08-03 22:51 UTC (permalink / raw)
  To: Haoxiang Li
  Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona, sam,
	dri-devel, linux-kernel, stable

On Thu, Jul 03, 2025 at 05:28:19PM +0800, Haoxiang Li wrote:
> Add check for the return value of kstrdup_const() in drm_managed.c
> to prevent potential null pointer dereference.
> 
> Fixes: c6603c740e0e ("drm: add managed resources tied to drm_device")
> Cc: stable@vger.kernel.org
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
> ---
>  drivers/gpu/drm/drm_managed.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_managed.c b/drivers/gpu/drm/drm_managed.c
> index cc4c463daae7..368763d4c24e 100644
> --- a/drivers/gpu/drm/drm_managed.c
> +++ b/drivers/gpu/drm/drm_managed.c
> @@ -151,6 +151,11 @@ int __drmm_add_action(struct drm_device *dev,
>  	}
>  
>  	dr->node.name = kstrdup_const(name, GFP_KERNEL);
> +	if (!dr->node.name) {
> +		kfree(dr);
> +		return -ENOMEM;
> +	}
> +
>  	if (data) {
>  		void_ptr = (void **)&dr->data;
>  		*void_ptr = data;
> @@ -236,6 +241,10 @@ void *drmm_kmalloc(struct drm_device *dev, size_t size, gfp_t gfp)
>  		return NULL;
>  	}
>  	dr->node.name = kstrdup_const("kmalloc", gfp);
> +	if (dr->node.name) {

This should be `if (!dr->node.name)`.
I think with this fixed the patch is legit and  should be picked up.

> +		kfree(dr);
> +		return NULL;
> +	}
>  
>  	add_dr(dev, dr);
>  
> -- 
> 2.25.1
> 

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-03 22:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-03  9:28 [PATCH RESEND] drm: Fix potential null pointer dereference issues in drm_managed.c Haoxiang Li
2025-07-16  2:34 ` kernel test robot
2025-08-03 22:51 ` Dmitry Baryshkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).