mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Ding Xiang <dingxiang@cmss.chinamobile.com>,
	ralf@linux-mips.org, paul.burton@mips.com, jhogan@kernel.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mips: txx9: fix resource leak after register fail
Date: Wed, 5 Sep 2018 12:50:34 +0300	[thread overview]
Message-ID: <19c418d6-229c-59e5-ee8e-5dfd12a0355b@cogentembedded.com> (raw)
In-Reply-To: <1536133287-21110-1-git-send-email-dingxiang@cmss.chinamobile.com>

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

      reply	other threads:[~2018-09-05  9:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05  7:41 Ding Xiang
2018-09-05  9:50 ` Sergei Shtylyov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19c418d6-229c-59e5-ee8e-5dfd12a0355b@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=dingxiang@cmss.chinamobile.com \
    --cc=jhogan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=paul.burton@mips.com \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®