Skip to contentSkip to conversation

Can also be NULL false positive

SMATCH Ethan Tidmore 2 participants 3 messages Apr 7 – Apr 8

lore
Share & tools
lore
#0 lore raw

Hi Dan,

Smatch gives these two warnings:

drivers/gpu/drm/i915/display/intel_crtc.c:333 __intel_crtc_init() warn: 'primary' can also be NULL drivers/gpu/drm/i915/display/intel_crtc.c:348 __intel_crtc_init() warn: 'plane' can also be NULL

	if (DISPLAY_VER(display) >= 9)
		primary = skl_universal_plane_create(display, pipe, PLANE_1);
	else
		primary = intel_primary_plane_create(display, pipe);
	if (IS_ERR(primary)) {
		ret = PTR_ERR(primary);
		goto fail;
	}
	crtc->plane_ids_mask |= BIT(primary->id);

and

		if (DISPLAY_VER(display) >= 9)
			plane = skl_universal_plane_create(display, pipe, PLANE_2 + sprite);
		else
			plane = intel_sprite_plane_create(display, pipe, sprite);
		if (IS_ERR(plane)) {
			ret = PTR_ERR(plane);
			goto fail;
		}
		crtc->plane_ids_mask |= BIT(plane->id);

But, this is a false positive because skl_universal_plane_create() and intel_sprite_plane_create() never return NULL and always error pointers.

Thanks,

ET

#1 lore raw
Quoted 29 lines · Ethan Tidmore

Hi Dan,

Smatch gives these two warnings:

drivers/gpu/drm/i915/display/intel_crtc.c:333 __intel_crtc_init() warn: 'primary' can also be NULL drivers/gpu/drm/i915/display/intel_crtc.c:348 __intel_crtc_init() warn: 'plane' can also be NULL

	if (DISPLAY_VER(display) >= 9)
		primary = skl_universal_plane_create(display, pipe, PLANE_1);
	else
		primary = intel_primary_plane_create(display, pipe);
	if (IS_ERR(primary)) {
		ret = PTR_ERR(primary);
		goto fail;
	}
	crtc->plane_ids_mask |= BIT(primary->id);

and

		if (DISPLAY_VER(display) >= 9)
			plane = skl_universal_plane_create(display, pipe, PLANE_2 + sprite);
		else
			plane = intel_sprite_plane_create(display, pipe, sprite);
		if (IS_ERR(plane)) {
			ret = PTR_ERR(plane);
			goto fail;
		}
		crtc->plane_ids_mask |= BIT(plane->id);
Quoted 2 lines

But, this is a false positive because skl_universal_plane_create() and intel_sprite_plane_create() never return NULL and always error pointers.

I don't see that warning on my builds.

One thing that I see is that intel_primary_plane_create() can return NULL if CONFIG_I915 is disabled. But I can't see how we would build that file without CONFIG_I915. I wondered if it might be a CONFIG_COMPILE_TEST thing, but I don't see that possibility.

Do you have the cross function DB built?

regards,
dan carpenter

#2 lore raw
Quoted 33 lines · Dan Carpenter
Quoted 29 lines · Ethan Tidmore

Hi Dan,

Smatch gives these two warnings:

drivers/gpu/drm/i915/display/intel_crtc.c:333 __intel_crtc_init() warn: 'primary' can also be NULL drivers/gpu/drm/i915/display/intel_crtc.c:348 __intel_crtc_init() warn: 'plane' can also be NULL

	if (DISPLAY_VER(display) >= 9)
		primary = skl_universal_plane_create(display, pipe, PLANE_1);
	else
		primary = intel_primary_plane_create(display, pipe);
	if (IS_ERR(primary)) {
		ret = PTR_ERR(primary);
		goto fail;
	}
	crtc->plane_ids_mask |= BIT(primary->id);

and

		if (DISPLAY_VER(display) >= 9)
			plane = skl_universal_plane_create(display, pipe, PLANE_2 + sprite);
		else
			plane = intel_sprite_plane_create(display, pipe, sprite);
		if (IS_ERR(plane)) {
			ret = PTR_ERR(plane);
			goto fail;
		}
		crtc->plane_ids_mask |= BIT(plane->id);
Quoted 2 lines

But, this is a false positive because skl_universal_plane_create() and intel_sprite_plane_create() never return NULL and always error pointers.

Quoted 8 lines

I don't see that warning on my builds.

One thing that I see is that intel_primary_plane_create() can return NULL if CONFIG_I915 is disabled. But I can't see how we would build that file without CONFIG_I915. I wondered if it might be a CONFIG_COMPILE_TEST thing, but I don't see that possibility.

Do you have the cross function DB built?

I'm building with 'allmodconfig' and using these smatch scripts:

./smatch/smatch_scripts/build_kernel_data.sh
./smatch/smatch_scripts/test_kernel.sh --endian

Thanks,

ET

Quoted 3 lines

regards,
dan carpenter