lkml.org 
[lkml]   [2018]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] mips: txx9: fix resource leak after register fail
From
Date
Hello!

On 9/5/2018 10:41 AM, Ding Xiang wrote:

> the memory allocated and ioremap address need free after
> device_register return error.
>
> Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.com>
> ---
> arch/mips/txx9/generic/setup.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
> index f6d9182..7f4fd2b 100644
> --- a/arch/mips/txx9/generic/setup.c
> +++ b/arch/mips/txx9/generic/setup.c
> @@ -961,11 +961,13 @@ void __init txx9_sramc_init(struct resource *r)
> err = sysfs_create_bin_file(&dev->dev.kobj, &dev->bindata_attr);
> if (err) {
> device_unregister(&dev->dev);
> - iounmap(dev->base);
> - kfree(dev);
> + goto exit_free;
> }
> return;
> exit_put:
> put_device(&dev->dev);
> +exit_free:
> + iounmap(dev->base);
> + kfree(dev);
> return;

*return* not needed here, never was needed.

> }

MBR, Sergei

\
 
 \ /
  Last update: 2018-09-05 11:51    [W:0.058 / U:18.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site