mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fabio Estevam <fabio.estevam@freescale.com>
To: <vinod.koul@intel.com>
Cc: <linux-kernel@vger.kernel.org>, <festevam@gmail.com>,
	Fabio Estevam <fabio.estevam@freescale.com>
Subject: [PATCH] dma: of-dma: Fix "'nbcells' may be used uninitialized" warning
Date: Mon, 20 May 2013 16:17:42 -0300	[thread overview]
Message-ID: <1369077462-19315-1-git-send-email-fabio.estevam@freescale.com> (raw)

Rearrange the code a bit so that we can get rid of the following build warning:

drivers/dma/of-dma.c:83:15: warning: 'nbcells' may be used uninitialized in this function [-Wuninitialized]

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/dma/of-dma.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c
index 7aa0864..107e820 100644
--- a/drivers/dma/of-dma.c
+++ b/drivers/dma/of-dma.c
@@ -77,15 +77,14 @@ int of_dma_controller_register(struct device_node *np,
 		return -ENOMEM;
 
 	prop = of_get_property(np, "#dma-cells", NULL);
-	if (prop)
-		nbcells = be32_to_cpup(prop);
+	if (!prop)
+		goto free;
+
+	nbcells = be32_to_cpup(prop);
 
-	if (!prop || !nbcells) {
-		pr_err("%s: #dma-cells property is missing or invalid\n",
-		       __func__);
-		kfree(ofdma);
-		return -EINVAL;
-	}
+
+	if (!nbcells)
+		goto free;
 
 	ofdma->of_node = np;
 	ofdma->of_dma_nbcells = nbcells;
@@ -98,6 +97,11 @@ int of_dma_controller_register(struct device_node *np,
 	mutex_unlock(&of_dma_lock);
 
 	return 0;
+
+free:
+	pr_err("%s: #dma-cells property is missing or invalid\n", __func__);
+	kfree(ofdma);
+	return -EINVAL;
 }
 EXPORT_SYMBOL_GPL(of_dma_controller_register);
 
-- 
1.8.1.2



             reply	other threads:[~2013-05-20 19:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-20 19:17 Fabio Estevam [this message]
2013-05-20 19:21 ` Lars-Peter Clausen

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=1369077462-19315-1-git-send-email-fabio.estevam@freescale.com \
    --to=fabio.estevam@freescale.com \
    --cc=festevam@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®