All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [patch v2] usb: gadget: f_midi: missing unlock on error path
Date: Tue, 05 Jan 2016 22:08:27 +0000	[thread overview]
Message-ID: <20160105220827.GF23363@mwanda> (raw)
In-Reply-To: <20160105102809.GA26420@mwanda>

On Tue, Jan 05, 2016 at 08:51:18PM +0000, Felipe Ferreri Tonello wrote:
> This case is not a matter of been pretty but a matter of been less error
> prone.
> 
> What would you suggest?

Normally it's better to unwind in the reverse order from how we
allocated so it would be:

	lock
	allocate midi
	allocate ports

	free ports
	free midi
	unlock

We could move the midi allocation outside the lock, but we can't move
ports allocation.  And also we want to drop the lock as soon as we can
so it's better to do that early like my patch does instead of after the
frees.  It's less symetric that way and thus more error prone but it's
better for performance.

Anyway, I don't think it really matters, this is a minor thing.

Also I hope that Smatch will be able to avoid that false positive about
the midi dereference by the end of 2016. :)

regards,
dan carpenter

  parent reply	other threads:[~2016-01-05 22:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-05 10:28 [patch v2] usb: gadget: f_midi: missing unlock on error path Dan Carpenter
2016-01-05 11:53 ` kbuild test robot
2016-01-05 12:28 ` Julia Lawall
2016-01-05 12:37 ` Dan Carpenter
2016-01-05 12:44 ` Dan Carpenter
2016-01-05 13:55 ` Michal Nazarewicz
2016-01-05 14:03 ` Dan Carpenter
2016-01-05 20:51 ` Felipe Ferreri Tonello
2016-01-05 21:21 ` Julia Lawall
2016-01-05 22:08 ` Dan Carpenter [this message]
2016-01-06  0:02 ` Michal Nazarewicz

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=20160105220827.GF23363@mwanda \
    --to=dan.carpenter@oracle.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.