All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] drm/tilcdc: fix leak & null ref in panel_connector_get_modes
@ 2020-04-29 10:42 Tomi Valkeinen
  2020-04-29 10:42 ` [PATCH 2/3] drm/tilcdc: remove unnecessary state->fb check Tomi Valkeinen
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Tomi Valkeinen @ 2020-04-29 10:42 UTC (permalink / raw)
  To: dri-devel, Jyri Sarha; +Cc: Tomi Valkeinen

If videomode_from_timings() returns true, the mode allocated with
drm_mode_create will be leaked.

Also, the return value of drm_mode_create() is never checked, and thus
could cause NULL deref.

Fix these two issues.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/tilcdc/tilcdc_panel.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
index 5584e656b857..f66e2f2a1a35 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
@@ -143,12 +143,16 @@ static int panel_connector_get_modes(struct drm_connector *connector)
 	int i;
 
 	for (i = 0; i < timings->num_timings; i++) {
-		struct drm_display_mode *mode = drm_mode_create(dev);
+		struct drm_display_mode *mode;
 		struct videomode vm;
 
 		if (videomode_from_timings(timings, &vm, i))
 			break;
 
+		mode =  drm_mode_create(dev);
+		if (!mode)
+			break;
+
 		drm_display_mode_from_videomode(&vm, mode);
 
 		mode->type = DRM_MODE_TYPE_DRIVER;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/3] drm/tilcdc: remove unnecessary state->fb check
  2020-04-29 10:42 [PATCH 1/3] drm/tilcdc: fix leak & null ref in panel_connector_get_modes Tomi Valkeinen
@ 2020-04-29 10:42 ` Tomi Valkeinen
  2020-05-19  6:06   ` Jyri Sarha
  2020-04-29 10:42 ` [PATCH 3/3] drm/tilcdc: add missing static for panel_driver Tomi Valkeinen
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Tomi Valkeinen @ 2020-04-29 10:42 UTC (permalink / raw)
  To: dri-devel, Jyri Sarha; +Cc: Tomi Valkeinen

tilcdc_plane_atomic_check() exits if state->fb == NULL, so no need to
check it again later.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/tilcdc/tilcdc_plane.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
index e2090020b3a0..0d09b31ae759 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
@@ -62,8 +62,7 @@ static int tilcdc_plane_atomic_check(struct drm_plane *plane,
 		return -EINVAL;
 	}
 
-	if (state->fb && old_state->fb &&
-	    state->fb->format != old_state->fb->format) {
+	if (old_state->fb && state->fb->format != old_state->fb->format) {
 		dev_dbg(plane->dev->dev,
 			"%s(): pixel format change requires mode_change\n",
 			__func__);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/3] drm/tilcdc: add missing static for panel_driver
  2020-04-29 10:42 [PATCH 1/3] drm/tilcdc: fix leak & null ref in panel_connector_get_modes Tomi Valkeinen
  2020-04-29 10:42 ` [PATCH 2/3] drm/tilcdc: remove unnecessary state->fb check Tomi Valkeinen
@ 2020-04-29 10:42 ` Tomi Valkeinen
  2020-05-06 19:04   ` Sam Ravnborg
  2020-05-19  6:07   ` Jyri Sarha
  2020-05-06 19:02 ` [PATCH 1/3] drm/tilcdc: fix leak & null ref in panel_connector_get_modes Sam Ravnborg
  2020-05-19  6:06 ` Jyri Sarha
  3 siblings, 2 replies; 9+ messages in thread
From: Tomi Valkeinen @ 2020-04-29 10:42 UTC (permalink / raw)
  To: dri-devel, Jyri Sarha; +Cc: Tomi Valkeinen

struct platform_driver panel_driver is only used from tilcdc_panel.c, so
it can be static.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/tilcdc/tilcdc_panel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
index f66e2f2a1a35..cdc93a81b552 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
@@ -404,7 +404,7 @@ static const struct of_device_id panel_of_match[] = {
 		{ },
 };
 
-struct platform_driver panel_driver = {
+static struct platform_driver panel_driver = {
 	.probe = panel_probe,
 	.remove = panel_remove,
 	.driver = {
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] drm/tilcdc: fix leak & null ref in panel_connector_get_modes
  2020-04-29 10:42 [PATCH 1/3] drm/tilcdc: fix leak & null ref in panel_connector_get_modes Tomi Valkeinen
  2020-04-29 10:42 ` [PATCH 2/3] drm/tilcdc: remove unnecessary state->fb check Tomi Valkeinen
  2020-04-29 10:42 ` [PATCH 3/3] drm/tilcdc: add missing static for panel_driver Tomi Valkeinen
@ 2020-05-06 19:02 ` Sam Ravnborg
  2020-05-19  6:57   ` Tomi Valkeinen
  2020-05-19  6:06 ` Jyri Sarha
  3 siblings, 1 reply; 9+ messages in thread
From: Sam Ravnborg @ 2020-05-06 19:02 UTC (permalink / raw)
  To: Tomi Valkeinen; +Cc: Jyri Sarha, dri-devel

On Wed, Apr 29, 2020 at 01:42:32PM +0300, Tomi Valkeinen wrote:
> If videomode_from_timings() returns true, the mode allocated with
> drm_mode_create will be leaked.
> 
> Also, the return value of drm_mode_create() is never checked, and thus
> could cause NULL deref.
> 
> Fix these two issues.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
One nit
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/tilcdc/tilcdc_panel.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
> index 5584e656b857..f66e2f2a1a35 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
> @@ -143,12 +143,16 @@ static int panel_connector_get_modes(struct drm_connector *connector)
>  	int i;
>  
>  	for (i = 0; i < timings->num_timings; i++) {
> -		struct drm_display_mode *mode = drm_mode_create(dev);
> +		struct drm_display_mode *mode;
>  		struct videomode vm;
>  
>  		if (videomode_from_timings(timings, &vm, i))
>  			break;
>  
> +		mode =  drm_mode_create(dev);
extra space            ^
> +		if (!mode)
> +			break;
> +
>  		drm_display_mode_from_videomode(&vm, mode);
>  
>  		mode->type = DRM_MODE_TYPE_DRIVER;
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/3] drm/tilcdc: add missing static for panel_driver
  2020-04-29 10:42 ` [PATCH 3/3] drm/tilcdc: add missing static for panel_driver Tomi Valkeinen
@ 2020-05-06 19:04   ` Sam Ravnborg
  2020-05-19  6:07   ` Jyri Sarha
  1 sibling, 0 replies; 9+ messages in thread
From: Sam Ravnborg @ 2020-05-06 19:04 UTC (permalink / raw)
  To: Tomi Valkeinen; +Cc: Jyri Sarha, dri-devel

On Wed, Apr 29, 2020 at 01:42:34PM +0300, Tomi Valkeinen wrote:
> struct platform_driver panel_driver is only used from tilcdc_panel.c, so
> it can be static.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/tilcdc/tilcdc_panel.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
> index f66e2f2a1a35..cdc93a81b552 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
> @@ -404,7 +404,7 @@ static const struct of_device_id panel_of_match[] = {
>  		{ },
>  };
>  
> -struct platform_driver panel_driver = {
> +static struct platform_driver panel_driver = {
>  	.probe = panel_probe,
>  	.remove = panel_remove,
>  	.driver = {
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] drm/tilcdc: fix leak & null ref in panel_connector_get_modes
  2020-04-29 10:42 [PATCH 1/3] drm/tilcdc: fix leak & null ref in panel_connector_get_modes Tomi Valkeinen
                   ` (2 preceding siblings ...)
  2020-05-06 19:02 ` [PATCH 1/3] drm/tilcdc: fix leak & null ref in panel_connector_get_modes Sam Ravnborg
@ 2020-05-19  6:06 ` Jyri Sarha
  3 siblings, 0 replies; 9+ messages in thread
From: Jyri Sarha @ 2020-05-19  6:06 UTC (permalink / raw)
  To: Tomi Valkeinen, dri-devel

On 29/04/2020 13:42, Tomi Valkeinen wrote:
> If videomode_from_timings() returns true, the mode allocated with
> drm_mode_create will be leaked.
> 
> Also, the return value of drm_mode_create() is never checked, and thus
> could cause NULL deref.
> 
> Fix these two issues.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Jyri Sarha <jsarha@ti.com>

> ---
>  drivers/gpu/drm/tilcdc/tilcdc_panel.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
> index 5584e656b857..f66e2f2a1a35 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
> @@ -143,12 +143,16 @@ static int panel_connector_get_modes(struct drm_connector *connector)
>  	int i;
>  
>  	for (i = 0; i < timings->num_timings; i++) {
> -		struct drm_display_mode *mode = drm_mode_create(dev);
> +		struct drm_display_mode *mode;
>  		struct videomode vm;
>  
>  		if (videomode_from_timings(timings, &vm, i))
>  			break;
>  
> +		mode =  drm_mode_create(dev);
> +		if (!mode)
> +			break;
> +
>  		drm_display_mode_from_videomode(&vm, mode);
>  
>  		mode->type = DRM_MODE_TYPE_DRIVER;
> 


-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] drm/tilcdc: remove unnecessary state->fb check
  2020-04-29 10:42 ` [PATCH 2/3] drm/tilcdc: remove unnecessary state->fb check Tomi Valkeinen
@ 2020-05-19  6:06   ` Jyri Sarha
  0 siblings, 0 replies; 9+ messages in thread
From: Jyri Sarha @ 2020-05-19  6:06 UTC (permalink / raw)
  To: Tomi Valkeinen, dri-devel

On 29/04/2020 13:42, Tomi Valkeinen wrote:
> tilcdc_plane_atomic_check() exits if state->fb == NULL, so no need to
> check it again later.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Jyri Sarha <jsarha@ti.com>

> ---
>  drivers/gpu/drm/tilcdc/tilcdc_plane.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
> index e2090020b3a0..0d09b31ae759 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
> @@ -62,8 +62,7 @@ static int tilcdc_plane_atomic_check(struct drm_plane *plane,
>  		return -EINVAL;
>  	}
>  
> -	if (state->fb && old_state->fb &&
> -	    state->fb->format != old_state->fb->format) {
> +	if (old_state->fb && state->fb->format != old_state->fb->format) {
>  		dev_dbg(plane->dev->dev,
>  			"%s(): pixel format change requires mode_change\n",
>  			__func__);
> 


-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/3] drm/tilcdc: add missing static for panel_driver
  2020-04-29 10:42 ` [PATCH 3/3] drm/tilcdc: add missing static for panel_driver Tomi Valkeinen
  2020-05-06 19:04   ` Sam Ravnborg
@ 2020-05-19  6:07   ` Jyri Sarha
  1 sibling, 0 replies; 9+ messages in thread
From: Jyri Sarha @ 2020-05-19  6:07 UTC (permalink / raw)
  To: Tomi Valkeinen, dri-devel

On 29/04/2020 13:42, Tomi Valkeinen wrote:
> struct platform_driver panel_driver is only used from tilcdc_panel.c, so
> it can be static.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Jyri Sarha <jsarha@ti.com>

> ---
>  drivers/gpu/drm/tilcdc/tilcdc_panel.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
> index f66e2f2a1a35..cdc93a81b552 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
> @@ -404,7 +404,7 @@ static const struct of_device_id panel_of_match[] = {
>  		{ },
>  };
>  
> -struct platform_driver panel_driver = {
> +static struct platform_driver panel_driver = {
>  	.probe = panel_probe,
>  	.remove = panel_remove,
>  	.driver = {
> 


-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] drm/tilcdc: fix leak & null ref in panel_connector_get_modes
  2020-05-06 19:02 ` [PATCH 1/3] drm/tilcdc: fix leak & null ref in panel_connector_get_modes Sam Ravnborg
@ 2020-05-19  6:57   ` Tomi Valkeinen
  0 siblings, 0 replies; 9+ messages in thread
From: Tomi Valkeinen @ 2020-05-19  6:57 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Jyri Sarha, dri-devel

On 06/05/2020 22:02, Sam Ravnborg wrote:
> On Wed, Apr 29, 2020 at 01:42:32PM +0300, Tomi Valkeinen wrote:
>> If videomode_from_timings() returns true, the mode allocated with
>> drm_mode_create will be leaked.
>>
>> Also, the return value of drm_mode_create() is never checked, and thus
>> could cause NULL deref.
>>
>> Fix these two issues.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> One nit
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
>> ---
>>   drivers/gpu/drm/tilcdc/tilcdc_panel.c | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
>> index 5584e656b857..f66e2f2a1a35 100644
>> --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c
>> +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
>> @@ -143,12 +143,16 @@ static int panel_connector_get_modes(struct drm_connector *connector)
>>   	int i;
>>   
>>   	for (i = 0; i < timings->num_timings; i++) {
>> -		struct drm_display_mode *mode = drm_mode_create(dev);
>> +		struct drm_display_mode *mode;
>>   		struct videomode vm;
>>   
>>   		if (videomode_from_timings(timings, &vm, i))
>>   			break;
>>   
>> +		mode =  drm_mode_create(dev);
> extra space            ^

Thanks! Fixed this.

  Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-05-19  6:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29 10:42 [PATCH 1/3] drm/tilcdc: fix leak & null ref in panel_connector_get_modes Tomi Valkeinen
2020-04-29 10:42 ` [PATCH 2/3] drm/tilcdc: remove unnecessary state->fb check Tomi Valkeinen
2020-05-19  6:06   ` Jyri Sarha
2020-04-29 10:42 ` [PATCH 3/3] drm/tilcdc: add missing static for panel_driver Tomi Valkeinen
2020-05-06 19:04   ` Sam Ravnborg
2020-05-19  6:07   ` Jyri Sarha
2020-05-06 19:02 ` [PATCH 1/3] drm/tilcdc: fix leak & null ref in panel_connector_get_modes Sam Ravnborg
2020-05-19  6:57   ` Tomi Valkeinen
2020-05-19  6:06 ` Jyri Sarha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.