lkml.org 
[lkml]   [2019]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] pcm030-audio-fabric: Fix a memory leaking bug in pcm030_fabric_probe()
From
Date

On 24/05/2019 03:12, Gen Zhang wrote:
> In pcm030_fabric_probe(), 'pdata->codec_device' is allocated by
> platform_device_alloc(). When this allocation fails, ENOMEM is returned.
> However, 'pdata' is allocated by devm_kzalloc() before this site. We
> should free 'pdata' before function ends to prevent memory leaking.
>
> Similarly, we should free 'pdata' when 'pdata->codec_device' is NULL.
> And we should free 'pdata->codec_device' and 'pdata' when 'ret' is error
> to prevent memory leaking.
>
> Signed-off-by: Gen Zhang <blackgod016574@gmail.com>

I have seen several of these patches now, and this is not correct. I
think you need to understand how devm_kzalloc() works.

Jon

--
nvpublic

\
 
 \ /
  Last update: 2019-05-24 11:31    [W:0.039 / U:0.516 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site