[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <279050e0-39e4-173d-ffe8-c1837951f4d1@nvidia.com>
Date: Fri, 24 May 2019 10:42:25 +0100
From: Jon Hunter <jonathanh@...dia.com>
To: Gen Zhang <blackgod016574@...il.com>, <kvalo@...eaurora.org>,
<davem@...emloft.net>
CC: <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] spi: Fix a memory leaking bug in wl1271_probe()
On 23/05/2019 15:30, Gen Zhang wrote:
> In wl1271_probe(), 'glue->core' is allocated by platform_device_alloc(),
> when this allocation fails, ENOMEM is returned. However, 'pdev_data'
> and 'glue' are allocated by devm_kzalloc() before 'glue->core'. When
> platform_device_alloc() returns NULL, we should also free 'pdev_data'
> and 'glue' before wl1271_probe() ends to prevent leaking memory.
>
> Similarly, we shoulf free 'pdev_data' when 'glue' is NULL. And we should
> free 'pdev_data' and 'glue' when 'glue->reg' is error and when 'ret' is
> error.
>
> Further, we should free 'glue->core', 'pdev_data' and 'glue' when this
> function normally ends to prevent leaking memory.
>
> Signed-off-by: Gen Zhang <blackgod016574@...il.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
Powered by blists - more mailing lists