mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/5] sandbox: do not register device before base is started
Date: Thu, 20 Sep 2012 07:35:19 +0200	[thread overview]
Message-ID: <20120920053519.GC26553@game.jcrosoft.org> (raw)
In-Reply-To: <20120919174153.GM6180@pengutronix.de>

On 19:41 Wed 19 Sep     , Sascha Hauer wrote:
> On Wed, Sep 19, 2012 at 04:47:55PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > This will crash when use registered bus with device registered to it.
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> >  arch/sandbox/board/Makefile   |    1 +
> >  arch/sandbox/board/console.c  |    2 +-
> >  arch/sandbox/board/devices.c  |   35 +++++++++++++++++++++++++++++++++++
> >  arch/sandbox/board/hostfile.c |   19 +++++++++++++++++--
> >  4 files changed, 54 insertions(+), 3 deletions(-)
> >  create mode 100644 arch/sandbox/board/devices.c
> > 
> > diff --git a/arch/sandbox/board/Makefile b/arch/sandbox/board/Makefile
> > index 266c3a3..5104f5c 100644
> > --- a/arch/sandbox/board/Makefile
> > +++ b/arch/sandbox/board/Makefile
> > @@ -2,5 +2,6 @@ obj-y += board.o
> >  obj-y += clock.o
> >  obj-y += hostfile.o
> >  obj-y += console.o
> > +obj-y += devices.o
> >  
> >  extra-y += barebox.lds
> > diff --git a/arch/sandbox/board/console.c b/arch/sandbox/board/console.c
> > index 18b63e1..b0afa54 100644
> > --- a/arch/sandbox/board/console.c
> > +++ b/arch/sandbox/board/console.c
> > @@ -44,6 +44,6 @@ int barebox_register_console(char *name, int stdinfd, int stdoutfd)
> >  	data->stdoutfd = stdoutfd;
> >  	data->stdinfd  = stdinfd;
> >  
> > -	return register_device(dev);
> > +	return sandbox_add_device(dev);
> >  }
> >  
> > diff --git a/arch/sandbox/board/devices.c b/arch/sandbox/board/devices.c
> > new file mode 100644
> > index 0000000..d3fad78
> > --- /dev/null
> > +++ b/arch/sandbox/board/devices.c
> > @@ -0,0 +1,35 @@
> > +/*
> > + * Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > + *
> > + * Under GPLv2 only
> > + */
> > +
> > +#include <common.h>
> > +#include <driver.h>
> > +#include <init.h>
> > +
> > +static LIST_HEAD(sandbox_device_list);
> > +
> > +int sandbox_add_device(struct device_d *dev)
> > +{
> > +	if (!dev)
> > +		return -EINVAL;
> 
> Can we please agree that everyone registering NULL pointers deserves a
> nice crash? I do not see a reason to check this. All these kinds of
> checks do is cover bugs and make tracking them down harder.
I agree but not on the crash we need to use BUG_ON

Best Regards,
J.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-09-20  5:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-19 14:43 [PATCH 0/5 v2] sandbox fix + bus Jean-Christophe PLAGNIOL-VILLARD
2012-09-19 14:47 ` [PATCH 1/5] sandbox: check only image option in the second getopt Jean-Christophe PLAGNIOL-VILLARD
2012-09-19 14:47   ` [PATCH 2/5] sandbox: do not register device before base is started Jean-Christophe PLAGNIOL-VILLARD
2012-09-19 17:41     ` Sascha Hauer
2012-09-20  5:35       ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-09-19 14:47   ` [PATCH 3/5] net/tap: use xzalloc to allocate data Jean-Christophe PLAGNIOL-VILLARD
2012-09-19 14:47   ` [PATCH 4/5] driver: register bus Jean-Christophe PLAGNIOL-VILLARD
2012-09-19 14:47   ` [PATCH 5/5] driver: search device and driver based on the bus instead of all Jean-Christophe PLAGNIOL-VILLARD

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=20120920053519.GC26553@game.jcrosoft.org \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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