]> www.infradead.org Git - users/jedix/linux-maple.git/commit
drm/omap: Fix possible NULL dereference
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Tue, 6 Aug 2024 13:50:27 +0000 (16:50 +0300)
committerTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Mon, 16 Sep 2024 04:12:39 +0000 (07:12 +0300)
commita88fee2d67d9b78c24630a987a88ccf886b2498b
tree6c6a785d31e19d825b26c8d16cae0c9f7f9d8e48
parentef77507bc849dea5cd6d216614f58763bd19ff4c
drm/omap: Fix possible NULL dereference

smatch reports:

drivers/gpu/drm/omapdrm/dss/base.c:176 omapdss_device_disconnect() error: we previously assumed 'src' could be null (see line 169)

This code is mostly from a time when omapdrm had its own display device
model. I can't honestly remember the details, and I don't think it's
worth digging in deeply into that for a legacy driver.

However, it looks like we only call omapdss_device_disconnect() and
omapdss_device_connect() with NULL as the src parameter. We can thus
drop the src parameter from both functions, and fix the smatch warning.

I don't think omapdss_device_disconnect() ever gets NULL for the dst
parameter (if it did, we'd crash soon after returning from the
function), but I have kept the !dst check, just in case, but I added a
WARN_ON() there.

Also, if the dst parameter can be NULL, we can't always get the struct
dss_device pointer from dst->dss (which is only used for a debug print).
To make sure we can't hit that issue, do it similarly to the
omapdss_device_connect() function: add 'struct dss_device *dss' as the
first parameter, so that we always have it regardless of the dst.

Fixes: 79107f274b2f ("drm/omap: Add support for drm_bridge")
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240806-omapdrm-misc-fixes-v1-1-15d31aea0831@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/base.c
drivers/gpu/drm/omapdrm/dss/omapdss.h
drivers/gpu/drm/omapdrm/omap_drv.c