mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Gernot Vormayr <gvormayr@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jens Axboe <axboe@kernel.dk>,
	linux-kernel@vger.kernel.org,
	Grant Likely <grant.likely@secretlab.ca>,
	Rob Herring <rob.herring@calxeda.com>
Subject: Re: [RESEND] [PATCH 1/1] block: Fix id of xsysace with missing port-number
Date: Tue, 7 May 2013 14:40:30 -0700	[thread overview]
Message-ID: <20130507144030.952018c4c71dd6d990a195ea@linux-foundation.org> (raw)
In-Reply-To: <1367526465-31886-1-git-send-email-gvormayr@gmail.com>

On Thu,  2 May 2013 22:27:45 +0200 Gernot Vormayr <gvormayr@gmail.com> wrote:

> If the port number is missing from the device-tree the device gets
> named xs` instead of xsa. This fixes the check for missing ids.
> 
> Tested on ml507 board.
> 
> Signed-off-by: Gernot Vormayr <gvormayr@gmail.com>
> ---
>  drivers/block/xsysace.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
> index 1f38643..6b5807a 100644
> --- a/drivers/block/xsysace.c
> +++ b/drivers/block/xsysace.c
> @@ -1161,8 +1161,7 @@ static int ace_probe(struct platform_device *dev)
>  	dev_dbg(&dev->dev, "ace_probe(%p)\n", dev);
>  
>  	/* device id and bus width */
> -	of_property_read_u32(dev->dev.of_node, "port-number", &id);
> -	if (id < 0)
> +	if (of_property_read_u32(dev->dev.of_node, "port-number", &id))
>  		id = 0;
>  	if (of_find_property(dev->dev.of_node, "8-bit", NULL))
>  		bus_width = ACE_BUS_WIDTH_8;

err, yes.  If of_property_read_u32() fails to locate the property, `id'
remains unaltered.  That code appears to believe that
of_property_read_u32() puts its errno into `id'.

AFAICT, it is always a bug to fail to check the of_property_read()
return value (unless the caller somehow *knows* the property exists?). 
Perhaps these functions should be marked __must_check to locate and
prevent such bugs.



      reply	other threads:[~2013-05-07 21:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-02 20:27 Gernot Vormayr
2013-05-07 21:40 ` Andrew Morton [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=20130507144030.952018c4c71dd6d990a195ea@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=grant.likely@secretlab.ca \
    --cc=gregkh@linuxfoundation.org \
    --cc=gvormayr@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rob.herring@calxeda.com \
    /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®