All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Edmundo Carmona Antoranz <eantoranz@gmail.com>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] ACPI: scan: Fix a memory leak in an error handling path
Date: Mon, 10 May 2021 16:55:30 +0300	[thread overview]
Message-ID: <20210510135529.GS1922@kadam> (raw)
In-Reply-To: <CAOc6etbVZkANHVVmP5rss-nQqSYNiSFRXrg_nVUBV-719xKqJw@mail.gmail.com>

On Mon, May 10, 2021 at 07:18:14AM -0600, Edmundo Carmona Antoranz wrote:
> On Sun, May 9, 2021 at 11:40 PM Dan Carpenter <dan.carpenter@oracle.com>
> wrote:
> 
> >
> > The best way to write error handling is "free the last resource style"
> > where you free the most recent resouce that was successfully allocated.
> > That way in your head you just have to keep track of one thing, instead
> > of tracking everything.
> >
> 
> IC. So the answer is rather: single place to free stuff? Yes..... _but_ in
> a layered fashion (through tags) instead of having a single tag to take
> care of everything.
> 
> Follow up question: is it worth making a patch to try to simplify a
> function to have error handling set up this way for code that is already
> working? Or not really?
> 

No, absolutely not.  This is just my preference and probably the most
common way to write error handling but it's not an official standard.

Plus it super easy to find error handling code which is not working and
fix that instead.

regards,
dan carpenter


  parent reply	other threads:[~2021-05-10 13:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-08  7:23 [PATCH] ACPI: scan: Fix a memory leak in an error handling path Christophe JAILLET
2021-05-08 14:50 ` Edmundo Carmona Antoranz
2021-05-08 18:47   ` Christophe JAILLET
2021-05-10  5:39   ` Dan Carpenter
     [not found]     ` <CAOc6etbVZkANHVVmP5rss-nQqSYNiSFRXrg_nVUBV-719xKqJw@mail.gmail.com>
2021-05-10 13:55       ` Dan Carpenter [this message]
2021-05-10 12:18 ` Andy Shevchenko
2021-05-10 17:04   ` Rafael J. Wysocki

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=20210510135529.GS1922@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=eantoranz@gmail.com \
    --cc=kernel-janitors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.