All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] drm/gem: Add drm_gem_object_funcs
@ 2022-10-26  9:59 Dan Carpenter
  2022-10-26 11:24 ` Dmitry Osipenko
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-10-26  9:59 UTC (permalink / raw)
  To: noralf, Dmitry Osipenko; +Cc: dri-devel

Hello Noralf Trønnes,

The patch b39b5394fabc: "drm/gem: Add drm_gem_object_funcs" from Nov
10, 2018, leads to the following Smatch static checker warning:

	drivers/gpu/drm/drm_client.c:240 drm_client_buffer_delete()
	warn: variable dereferenced before check 'buffer->gem' (see line 238)

drivers/gpu/drm/drm_client.c
    234 static void drm_client_buffer_delete(struct drm_client_buffer *buffer)
    235 {
    236         struct drm_device *dev = buffer->client->dev;
    237 
    238         drm_gem_vunmap_unlocked(buffer->gem, &buffer->map);
                                        ^^^^^^^^^^^
Unchecked dereference inside function call.

    239 
--> 240         if (buffer->gem)
                    ^^^^^^^^^^^
Too late.  I don't honestly, know why this warning is only showing up
now four years later.  Perhaps Smatch thought buffer->gem was always
non-NULL before but now it's not sure.  I've added Dmitry to the CC list
because he seems to has been working in this area recently and might
know what's going on.

    241                 drm_gem_object_put(buffer->gem);
    242 
    243         if (buffer->handle)
    244                 drm_mode_destroy_dumb(dev, buffer->handle, buffer->client->file);
    245 
    246         kfree(buffer);
    247 }

regards,
dan carpenter

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

* Re: [bug report] drm/gem: Add drm_gem_object_funcs
  2022-10-26  9:59 [bug report] drm/gem: Add drm_gem_object_funcs Dan Carpenter
@ 2022-10-26 11:24 ` Dmitry Osipenko
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Osipenko @ 2022-10-26 11:24 UTC (permalink / raw)
  To: Dan Carpenter, noralf; +Cc: dri-devel

On 10/26/22 12:59, Dan Carpenter wrote:
> Hello Noralf Trønnes,
> 
> The patch b39b5394fabc: "drm/gem: Add drm_gem_object_funcs" from Nov
> 10, 2018, leads to the following Smatch static checker warning:
> 
> 	drivers/gpu/drm/drm_client.c:240 drm_client_buffer_delete()
> 	warn: variable dereferenced before check 'buffer->gem' (see line 238)
> 
> drivers/gpu/drm/drm_client.c
>     234 static void drm_client_buffer_delete(struct drm_client_buffer *buffer)
>     235 {
>     236         struct drm_device *dev = buffer->client->dev;
>     237 
>     238         drm_gem_vunmap_unlocked(buffer->gem, &buffer->map);
>                                         ^^^^^^^^^^^
> Unchecked dereference inside function call.
> 
>     239 
> --> 240         if (buffer->gem)
>                     ^^^^^^^^^^^
> Too late.  I don't honestly, know why this warning is only showing up
> now four years later.  Perhaps Smatch thought buffer->gem was always
> non-NULL before but now it's not sure.  I've added Dmitry to the CC list
> because he seems to has been working in this area recently and might
> know what's going on.

This is a valid bug. Before my changes drm_gem_vunmap() wasn't touching
buffer->gem when buffer->map=NULL, now it will. I'll prepare the fix,
thank you for the report.

-- 
Best regards,
Dmitry


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

end of thread, other threads:[~2022-10-26 11:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26  9:59 [bug report] drm/gem: Add drm_gem_object_funcs Dan Carpenter
2022-10-26 11:24 ` Dmitry Osipenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.