public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Paolo Pisati <paolo.pisati@canonical.com>
Cc: Vinod Koul <vinod.koul@intel.com>, Dan Williams <djbw@fb.com>,
	Grant Likely <grant.likely@secretlab.ca>,
	Rob Herring <rob.herring@calxeda.com>,
	linux-kernel@vger.kernel.org,
	devicetree-discuss@lists.ozlabs.org
Subject: Re: [PATCH] dma: of-dma: check OF pointer property before dereferencing it
Date: Mon, 15 Apr 2013 17:22:51 +0200	[thread overview]
Message-ID: <516C1B4B.2070806@metafoo.de> (raw)
In-Reply-To: <1366015193-6627-2-git-send-email-paolo.pisati@canonical.com>

On 04/15/2013 10:39 AM, Paolo Pisati wrote:
> Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>

That should already be fixed in the DMA tree. See commit 7362f04c28 ("DMA:
OF: Check properties value before running be32_to_cpup() on it").

- Lars


> ---
>  drivers/dma/of-dma.c |    7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c
> index 69d04d2..9628298 100644
> --- a/drivers/dma/of-dma.c
> +++ b/drivers/dma/of-dma.c
> @@ -91,6 +91,7 @@ int of_dma_controller_register(struct device_node *np,
>  				(struct of_phandle_args *, struct of_dma *),
>  				void *data)
>  {
> +	void 	*parent;
>  	struct of_dma	*ofdma;
>  	int		nbcells;
>  
> @@ -103,8 +104,10 @@ int of_dma_controller_register(struct device_node *np,
>  	if (!ofdma)
>  		return -ENOMEM;
>  
> -	nbcells = be32_to_cpup(of_get_property(np, "#dma-cells", NULL));
> -	if (!nbcells) {
> +	parent = of_get_property(np, "#dma-cells", NULL);
> +	if (parent)
> +		nbcells = be32_to_cpup(parent);
> +	if (!parent || !nbcells) {
>  		pr_err("%s: #dma-cells property is missing or invalid\n",
>  		       __func__);
>  		kfree(ofdma);


      reply	other threads:[~2013-04-15 15:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-15  8:39 [PATCH] dma: of-dma: check OF pointer property before dereferencing Paolo Pisati
2013-04-15  8:39 ` [PATCH] dma: of-dma: check OF pointer property before dereferencing it Paolo Pisati
2013-04-15 15:22   ` Lars-Peter Clausen [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=516C1B4B.2070806@metafoo.de \
    --to=lars@metafoo.de \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=djbw@fb.com \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paolo.pisati@canonical.com \
    --cc=rob.herring@calxeda.com \
    --cc=vinod.koul@intel.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