diff mbox series

[-next] video: fbdev: pxafb: Fix "WARNING: invalid free of devm_ allocated data"

Message ID 20181116110255.19736-1-yuehaibing@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next] video: fbdev: pxafb: Fix "WARNING: invalid free of devm_ allocated data" | expand

Commit Message

Yue Haibing Nov. 16, 2018, 11:02 a.m. UTC
'info->modes' got allocated with devm_kcalloc in of_get_pxafb_display.

This gives this error message:
  ./drivers/video/fbdev/pxafb.c:2238:2-7: WARNING: invalid free of devm_ allocated data

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/video/fbdev/pxafb.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Daniel Mack Nov. 16, 2018, 8:05 p.m. UTC | #1
On 16/11/2018 12:02 PM, YueHaibing wrote:
> 'info->modes' got allocated with devm_kcalloc in of_get_pxafb_display.
> 
> This gives this error message:
>    ./drivers/video/fbdev/pxafb.c:2238:2-7: WARNING: invalid free of devm_ allocated data
> 
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Oh, yes. Thanks for spotting this!

Could you please add these lines to the patch and resubmit?


Fixes: c8f96304ec8b4 ("video: fbdev: pxafb: switch to devm_* API")
Cc: stable@kernel.org [v4.19+]
Reviewed-by: Daniel Mack <daniel@zonque.org>




> ---
>   drivers/video/fbdev/pxafb.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
> index bbed039..d59c8a5 100644
> --- a/drivers/video/fbdev/pxafb.c
> +++ b/drivers/video/fbdev/pxafb.c
> @@ -2234,10 +2234,8 @@ static struct pxafb_mach_info *of_pxafb_of_mach_info(struct device *dev)
>   	if (!info)
>   		return ERR_PTR(-ENOMEM);
>   	ret = of_get_pxafb_mode_info(dev, info);
> -	if (ret) {
> -		kfree(info->modes);
> +	if (ret)
>   		return ERR_PTR(ret);
> -	}
>   
>   	/*
>   	 * On purpose, neither lccrX registers nor video memory size can be
>
Yue Haibing Nov. 19, 2018, 1:23 a.m. UTC | #2
On 2018/11/17 4:05, Daniel Mack wrote:
> On 16/11/2018 12:02 PM, YueHaibing wrote:
>> 'info->modes' got allocated with devm_kcalloc in of_get_pxafb_display.
>>
>> This gives this error message:
>>    ./drivers/video/fbdev/pxafb.c:2238:2-7: WARNING: invalid free of devm_ allocated data
>>
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> 
> Oh, yes. Thanks for spotting this!
> 
> Could you please add these lines to the patch and resubmit?
> 

Sure, will send v2.

> 
> Fixes: c8f96304ec8b4 ("video: fbdev: pxafb: switch to devm_* API")
> Cc: stable@kernel.org [v4.19+]
> Reviewed-by: Daniel Mack <daniel@zonque.org>
> 
> 
> 
> 
>> ---
>>   drivers/video/fbdev/pxafb.c | 4 +---
>>   1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
>> index bbed039..d59c8a5 100644
>> --- a/drivers/video/fbdev/pxafb.c
>> +++ b/drivers/video/fbdev/pxafb.c
>> @@ -2234,10 +2234,8 @@ static struct pxafb_mach_info *of_pxafb_of_mach_info(struct device *dev)
>>       if (!info)
>>           return ERR_PTR(-ENOMEM);
>>       ret = of_get_pxafb_mode_info(dev, info);
>> -    if (ret) {
>> -        kfree(info->modes);
>> +    if (ret)
>>           return ERR_PTR(ret);
>> -    }
>>         /*
>>        * On purpose, neither lccrX registers nor video memory size can be
>>
> 
> 
> .
>
Bartlomiej Zolnierkiewicz Dec. 20, 2018, 4:55 p.m. UTC | #3
On 11/16/2018 12:02 PM, YueHaibing wrote:
> 'info->modes' got allocated with devm_kcalloc in of_get_pxafb_display.
> 
> This gives this error message:
>   ./drivers/video/fbdev/pxafb.c:2238:2-7: WARNING: invalid free of devm_ allocated data
> 
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Patch queued for 4.21, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
Bartlomiej Zolnierkiewicz Dec. 20, 2018, 4:56 p.m. UTC | #4
On 12/20/2018 05:55 PM, Bartlomiej Zolnierkiewicz wrote:
> 
> On 11/16/2018 12:02 PM, YueHaibing wrote:
>> 'info->modes' got allocated with devm_kcalloc in of_get_pxafb_display.
>>
>> This gives this error message:
>>   ./drivers/video/fbdev/pxafb.c:2238:2-7: WARNING: invalid free of devm_ allocated data
>>
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> 
> Patch queued for 4.21, thanks.

I've just noticed v2, I will queue it instead..

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
diff mbox series

Patch

diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
index bbed039..d59c8a5 100644
--- a/drivers/video/fbdev/pxafb.c
+++ b/drivers/video/fbdev/pxafb.c
@@ -2234,10 +2234,8 @@  static struct pxafb_mach_info *of_pxafb_of_mach_info(struct device *dev)
 	if (!info)
 		return ERR_PTR(-ENOMEM);
 	ret = of_get_pxafb_mode_info(dev, info);
-	if (ret) {
-		kfree(info->modes);
+	if (ret)
 		return ERR_PTR(ret);
-	}
 
 	/*
 	 * On purpose, neither lccrX registers nor video memory size can be