mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Pierre Ossman <drzeus-mmc@drzeus.cx>,
	David Brownell <dbrownell@users.sourceforge.net>,
	Grant Likely <grant.likely@secretlab.ca>,
	linuxppc-dev@ozlabs.org, Gary Jennejohn <garyj@denx.de>,
	Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 2/2] mmc: add OpenFirmware bindings for the mmc_spi driver
Date: Mon, 26 May 2008 15:58:26 +0400	[thread overview]
Message-ID: <20080526115826.GB26288@polina.dev.rtsoft.ru> (raw)
In-Reply-To: <20080524123527.04794974.sfr@canb.auug.org.au>

On Sat, May 24, 2008 at 12:35:27PM +1000, Stephen Rothwell wrote:
> Hi Anton,
> 
> On Fri, 23 May 2008 22:28:42 +0400 Anton Vorontsov <avorontsov@ru.mvista.com> wrote:
> >
> > +++ b/drivers/mmc/host/of_mmc_spi.c
> 
> > +static int of_mmc_spi_probe(struct spi_device *spi)
> 
> > +	/*
> > +	 * mmc_spi_probe will use drvdata, so we can't use it. Use node's
> > +	 * data instead.
> > +	 */
> > +	spi->dev.archdata.of_node->data = oms;
> 
> If you delay this assignment, you may not have to clean it up in the
> error path.

No, if I delay it I'll have to clean it up anyway, just a bit later
(after mmc_spi_probe() fail).

> > +	ocr_mask = of_get_property(np, "linux,mmc-ocr-mask", &size);
> 
> You should really explicitly include linux/of.h to use of_get_property etc

Thanks, will do.

> > +int __devexit of_mmc_spi_remove(struct spi_device *spi)
> > +{
> > +	struct of_mmc_spi *oms = spi->dev.archdata.of_node->data;
> > +	int ret;
> > +
> > +	ret = mmc_spi_remove(spi);
> > +	if (ret)
> > +		return ret;
> 
> Maybe you should do this last so that you don't leak more than necessary
> if mmc_spi_remove fails. (I don't know what state mmc_spi_remove leaves
> stuff in if it fails ...)

If I do this last, then of_mmc_spi_remove() would be not safe to call
multiple times on non-fatal errors (e.g. when mmc_spi_remove() returns
-EBUSY (despite that currently mmc_spi_remove can't fail)).

Also, if I do this last, then there will be a potential use-after-free
in the mmc_spi driver.

> > +static struct spi_driver of_mmc_spi_driver = {
> > +	.driver = {
> > +		.name = "of_mmc_spi",
> > +		.bus = &spi_bus_type,
> 
> This is initialised by spi_register_driver().

This was straight copy from the mmc_spi.c. Will fix.

Thanks,

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

  reply	other threads:[~2008-05-26 11:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-23 18:27 [RFC] OpenFirmware bindings for the MMC-over-SPI driver Anton Vorontsov
2008-05-23 18:28 ` [RFC PATCH 1/2] mmc_spi: export probe and remove functions Anton Vorontsov
2008-05-26 12:18   ` Pierre Ossman
2008-05-26 12:25     ` Anton Vorontsov
2008-05-26 13:10       ` Anton Vorontsov
2008-06-01 10:18         ` Pierre Ossman
2008-06-02 12:53           ` Anton Vorontsov
2008-06-05 21:16             ` Pierre Ossman
2008-05-23 18:28 ` [RFC PATCH 2/2] mmc: add OpenFirmware bindings for the mmc_spi driver Anton Vorontsov
2008-05-24  2:35   ` Stephen Rothwell
2008-05-26 11:58     ` Anton Vorontsov [this message]
2008-05-24  5:19   ` Grant Likely
2008-05-24 14:32     ` Jochen Friedrich
2008-05-24 23:14       ` Segher Boessenkool
2008-05-24 23:06     ` Segher Boessenkool
2008-05-26 11:49     ` Anton Vorontsov
2008-05-26 22:19       ` David Brownell
2008-05-26 23:15         ` Anton Vorontsov
2008-05-24 19:56 ` [RFC] OpenFirmware bindings for the MMC-over-SPI driver David Brownell
2008-05-25  4:47   ` Grant Likely

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=20080526115826.GB26288@polina.dev.rtsoft.ru \
    --to=avorontsov@ru.mvista.com \
    --cc=dbrownell@users.sourceforge.net \
    --cc=drzeus-mmc@drzeus.cx \
    --cc=g.liakhovetski@gmx.de \
    --cc=garyj@denx.de \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=sfr@canb.auug.org.au \
    /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

Powered by JetHome