Skip to content

Commit

Permalink
drm/stm: ltdc: fix late dereference check
Browse files Browse the repository at this point in the history
[ Upstream commit 898a9e3 ]

In ltdc_crtc_set_crc_source(), struct drm_crtc was dereferenced in a
container_of() before the pointer check. This could cause a kernel panic.

Fix this smatch warning:
drivers/gpu/drm/stm/ltdc.c:1124 ltdc_crtc_set_crc_source() warn: variable dereferenced before check 'crtc' (see line 1119)

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/lkml/202212241802.zeLFZCXB-lkp@intel.com/
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/lkml/202212241802.zeLFZCXB-lkp@intel.com/
Signed-off-by: Raphael Gallais-Pou <raphael.gallais-pou@foss.st.com>
Acked-by: Philippe Cornu <philippe.cornu@foss.st.com>
Signed-off-by: Philippe Cornu <philippe.cornu@foss.st.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230515123818.93971-1-raphael.gallais-pou@foss.st.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
rgallaispouSTM authored and gregkh committed Aug 23, 2023
1 parent f934cad commit 340dba1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/gpu/drm/stm/ltdc.c
Expand Up @@ -1145,14 +1145,16 @@ static void ltdc_crtc_disable_vblank(struct drm_crtc *crtc)

static int ltdc_crtc_set_crc_source(struct drm_crtc *crtc, const char *source)
{
struct ltdc_device *ldev = crtc_to_ltdc(crtc);
struct ltdc_device *ldev;
int ret;

DRM_DEBUG_DRIVER("\n");

if (!crtc)
return -ENODEV;

ldev = crtc_to_ltdc(crtc);

if (source && strcmp(source, "auto") == 0) {
ldev->crc_active = true;
ret = regmap_set_bits(ldev->regmap, LTDC_GCR, GCR_CRCEN);
Expand Down

0 comments on commit 340dba1

Please sign in to comment.