mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Arvind Yadav <arvind.yadav.cs@gmail.com>
Cc: baohua@kernel.org, daniel.lezcano@linaro.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] clocksource/timer-imx-gpt: Prevent resource leake in error path.
Date: Wed, 28 Sep 2016 15:10:27 -0400 (EDT)	[thread overview]
Message-ID: <alpine.DEB.2.20.1609281502180.4722@nanos> (raw)
In-Reply-To: <1475084605-8433-1-git-send-email-arvind.yadav.cs@gmail.com>

On Wed, 28 Sep 2016, Arvind Yadav wrote:

> -Free previously allocated memory.
> -Unmap I/O memory from kernel address space.

Ok. So we have proper looking patch with a proper looking changelog
now. Though
 
> @@ -507,11 +511,17 @@ static int __init mxc_timer_init_dt(struct device_node *np,  enum imx_gpt_type t
>  
>  	ret = _mxc_timer_init(imxtm);
>  	if (ret)
> -		return ret;
> +		goto error_iounmap;

Have you actually thought about the implications of this?

Assume the last function call() which gets invoked via _mxc_timer_init()
fails and then figure out what the iounmap() and the kfree() are going to
cause.

Hint: You just turned a resource leak into a fatal crash.

Just slapping unmap/kfree blindly at everything which can return a failure
is not a good idea if you do not check what the functions actually do and
what the error pathes there are.

While I agree that the error handling in this and in other drivers is
lousy, fixing it just mechanicaly and thereby introducing harder to debug
wreckage is certainly not the right approach.

Thanks,

	tglx

      reply	other threads:[~2016-09-28 19:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-28 17:43 Arvind Yadav
2016-09-28 19:10 ` Thomas Gleixner [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=alpine.DEB.2.20.1609281502180.4722@nanos \
    --to=tglx@linutronix.de \
    --cc=arvind.yadav.cs@gmail.com \
    --cc=baohua@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.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®