Re: [PATCH] drm/stm: ltdc: fix late dereference check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Raphael,

thanks for the patch.

Reviewed-by: Yannick Fertre <yannick.fertre@xxxxxxxxxxx>


On 4/12/23 11:25, Raphael GALLAIS-POU wrote:
Attention: Sender not authenticated
--------------------------------------------------

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@xxxxxxxxx>
Reported-by: Dan Carpenter <error27@xxxxxxxxx>
Link: https://lore.kernel.org/lkml/202212241802.zeLFZCXB-lkp@xxxxxxxxx/
Signed-off-by: Raphael Gallais-Pou <raphael.gallais-pou@xxxxxxxxxxx>
---
  drivers/gpu/drm/stm/ltdc.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index 03c6becda795..b8be4c1db423 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -1145,7 +1145,7 @@ 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");
@@ -1153,6 +1153,8 @@ static int ltdc_crtc_set_crc_source(struct drm_crtc *crtc, const char *source)
         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);
--
2.25.1




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux