* [PATCH RESEND] drm/stm: ltdc: fix late dereference check
@ 2023-05-15 12:38 Raphael Gallais-Pou
2023-05-26 9:13 ` Philippe CORNU
2023-05-26 11:40 ` Philippe CORNU
0 siblings, 2 replies; 3+ messages in thread
From: Raphael Gallais-Pou @ 2023-05-15 12:38 UTC (permalink / raw)
To: Yannick Fertre, Raphael Gallais-Pou, Philippe Cornu, David Airlie,
Daniel Vetter, Maxime Coquelin, Alexandre Torgue
Cc: dri-devel, linux-stm32, linux-arm-kernel, linux-kernel,
kernel test robot, Dan Carpenter
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>
Reported-by: Dan Carpenter <error27@gmail.com>
Link: https://lore.kernel.org/lkml/202212241802.zeLFZCXB-lkp@intel.com/
Signed-off-by: Raphael Gallais-Pou <raphael.gallais-pou@foss.st.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH RESEND] drm/stm: ltdc: fix late dereference check
2023-05-15 12:38 [PATCH RESEND] drm/stm: ltdc: fix late dereference check Raphael Gallais-Pou
@ 2023-05-26 9:13 ` Philippe CORNU
2023-05-26 11:40 ` Philippe CORNU
1 sibling, 0 replies; 3+ messages in thread
From: Philippe CORNU @ 2023-05-26 9:13 UTC (permalink / raw)
To: Raphael Gallais-Pou, Yannick Fertre, David Airlie, Daniel Vetter,
Maxime Coquelin, Alexandre Torgue
Cc: dri-devel, linux-stm32, linux-arm-kernel, linux-kernel,
kernel test robot, Dan Carpenter
On 5/15/23 14:38, Raphael Gallais-Pou wrote:
> 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>
> Reported-by: Dan Carpenter <error27@gmail.com>
> Link: https://lore.kernel.org/lkml/202212241802.zeLFZCXB-lkp@intel.com/
> Signed-off-by: Raphael Gallais-Pou <raphael.gallais-pou@foss.st.com>
> ---
> 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);
Hi Raphael,
and many thanks for your patch.
Acked-by: Philippe Cornu <philippe.cornu@foss.st.com>
Philippe :-)
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH RESEND] drm/stm: ltdc: fix late dereference check
2023-05-15 12:38 [PATCH RESEND] drm/stm: ltdc: fix late dereference check Raphael Gallais-Pou
2023-05-26 9:13 ` Philippe CORNU
@ 2023-05-26 11:40 ` Philippe CORNU
1 sibling, 0 replies; 3+ messages in thread
From: Philippe CORNU @ 2023-05-26 11:40 UTC (permalink / raw)
To: Raphael Gallais-Pou, Yannick Fertre, David Airlie, Daniel Vetter,
Maxime Coquelin, Alexandre Torgue
Cc: dri-devel, linux-stm32, linux-arm-kernel, linux-kernel,
kernel test robot, Dan Carpenter
On 5/15/23 14:38, Raphael Gallais-Pou wrote:
> 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>
> Reported-by: Dan Carpenter <error27@gmail.com>
> Link: https://lore.kernel.org/lkml/202212241802.zeLFZCXB-lkp@intel.com/
> Signed-off-by: Raphael Gallais-Pou <raphael.gallais-pou@foss.st.com>
> ---
> 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);
Hi Raphael,
Applied on drm-misc-next.
Note & fyi, I fixed the following warning, please be sure to follow this
rule next time :-)
WARNING:BAD_REPORTED_BY_LINK: Reported-by: should be immediately
followed by Closes: with a URL to the report
Many thanks for your patch,
Philippe :-)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-26 11:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-15 12:38 [PATCH RESEND] drm/stm: ltdc: fix late dereference check Raphael Gallais-Pou
2023-05-26 9:13 ` Philippe CORNU
2023-05-26 11:40 ` Philippe CORNU
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox