drm/tegra: Make CRTC upcasting safer
authorThierry Reding <treding@nvidia.com>
Fri, 8 Nov 2013 11:30:37 +0000 (12:30 +0100)
committerThierry Reding <treding@nvidia.com>
Tue, 3 Dec 2013 09:04:15 +0000 (10:04 +0100)
When upcasting a NULL CRTC object, propagate the NULL pointer instead of
some invalid pointer. This allows subsequent code to check that the cast
object is valid.

Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/gpu/drm/tegra/drm.h

index fdfe259..7da0b92 100644 (file)
@@ -116,7 +116,7 @@ host1x_client_to_dc(struct host1x_client *client)
 
 static inline struct tegra_dc *to_tegra_dc(struct drm_crtc *crtc)
 {
-       return container_of(crtc, struct tegra_dc, base);
+       return crtc ? container_of(crtc, struct tegra_dc, base) : NULL;
 }
 
 static inline void tegra_dc_writel(struct tegra_dc *dc, unsigned long value,