diff mbox series

[next] drm/panel: fix null pointer dereference on pointer mode

Message ID 20200918155136.28958-1-colin.king@canonical.com (mailing list archive)
State New, archived
Headers show
Series [next] drm/panel: fix null pointer dereference on pointer mode | expand

Commit Message

Colin King Sept. 18, 2020, 3:51 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Currently a null pointer check on pointer mode is passing mode to
function drm_mode_vrefresh and this causes a null pointer dereference
on mode.  Fix this by not calling drm_mode_vrefresh since the call
is only required for error reporting.

Addresses-Coverity: ("Dereference after null check")
Fixes: 72967d5616d3 ("drm/panel: Add panel driver for the Mantix MLAF057WE51-X DSI panel")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Guido Günther Sept. 18, 2020, 4:22 p.m. UTC | #1
Hi,
On Fri, Sep 18, 2020 at 04:51:36PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently a null pointer check on pointer mode is passing mode to
> function drm_mode_vrefresh and this causes a null pointer dereference
> on mode.  Fix this by not calling drm_mode_vrefresh since the call
> is only required for error reporting.
> 
> Addresses-Coverity: ("Dereference after null check")
> Fixes: 72967d5616d3 ("drm/panel: Add panel driver for the Mantix MLAF057WE51-X DSI panel")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c b/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
> index 3482e28e30fc..be4761a643f9 100644
> --- a/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
> +++ b/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
> @@ -202,9 +202,8 @@ static int mantix_get_modes(struct drm_panel *panel,
>  
>  	mode = drm_mode_duplicate(connector->dev, &default_mode);
>  	if (!mode) {
> -		dev_err(ctx->dev, "Failed to add mode %ux%u@%u\n",
> -			default_mode.hdisplay, default_mode.vdisplay,
> -			drm_mode_vrefresh(mode));
> +		dev_err(ctx->dev, "Failed to add mode %ux%u\n",
> +			default_mode.hdisplay, default_mode.vdisplay);
>  		return -ENOMEM;
>  	}

drm_mode_vrefresh(&default_mode) gives some more clue what's going on -
I have had a fix queued up in my tree already but if you send a v2
that's fine.

Thanks!
 -- Guido

>  
> -- 
> 2.27.0
>
Colin King Sept. 18, 2020, 4:39 p.m. UTC | #2
On 18/09/2020 17:22, Guido Günther wrote:
> Hi,
> On Fri, Sep 18, 2020 at 04:51:36PM +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Currently a null pointer check on pointer mode is passing mode to
>> function drm_mode_vrefresh and this causes a null pointer dereference
>> on mode.  Fix this by not calling drm_mode_vrefresh since the call
>> is only required for error reporting.
>>
>> Addresses-Coverity: ("Dereference after null check")
>> Fixes: 72967d5616d3 ("drm/panel: Add panel driver for the Mantix MLAF057WE51-X DSI panel")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c b/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
>> index 3482e28e30fc..be4761a643f9 100644
>> --- a/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
>> +++ b/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
>> @@ -202,9 +202,8 @@ static int mantix_get_modes(struct drm_panel *panel,
>>  
>>  	mode = drm_mode_duplicate(connector->dev, &default_mode);
>>  	if (!mode) {
>> -		dev_err(ctx->dev, "Failed to add mode %ux%u@%u\n",
>> -			default_mode.hdisplay, default_mode.vdisplay,
>> -			drm_mode_vrefresh(mode));
>> +		dev_err(ctx->dev, "Failed to add mode %ux%u\n",
>> +			default_mode.hdisplay, default_mode.vdisplay);
>>  		return -ENOMEM;
>>  	}
> 
> drm_mode_vrefresh(&default_mode) gives some more clue what's going on -
> I have had a fix queued up in my tree already but if you send a v2
> that's fine.

I'll defer to your queued up fix.
> 
> Thanks!
>  -- Guido
> 
>>  
>> -- 
>> 2.27.0
>>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c b/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
index 3482e28e30fc..be4761a643f9 100644
--- a/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
+++ b/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
@@ -202,9 +202,8 @@  static int mantix_get_modes(struct drm_panel *panel,
 
 	mode = drm_mode_duplicate(connector->dev, &default_mode);
 	if (!mode) {
-		dev_err(ctx->dev, "Failed to add mode %ux%u@%u\n",
-			default_mode.hdisplay, default_mode.vdisplay,
-			drm_mode_vrefresh(mode));
+		dev_err(ctx->dev, "Failed to add mode %ux%u\n",
+			default_mode.hdisplay, default_mode.vdisplay);
 		return -ENOMEM;
 	}