public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Vinod Koul <vinod.koul@intel.com>
Cc: Dan Williams <djbw@fb.com>,
	Grant Likely <grant.likely@linaro.org>,
	Rob Herring <rob.herring@calxeda.com>,
	devicetree@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] dma: mv_xor: error handling fix in mv_xor_channel_add()
Date: Thu, 22 Aug 2013 15:58:39 +0300	[thread overview]
Message-ID: <20130822125839.GC2543@elgon.mountain> (raw)

We haven't allocated the dma buffer at this point and also if we
"goto err_free_dma;" then it leads to a NULL dereference.  Just return
directly.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I can't compile this file.

diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index d9a2677..0e9e835 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -1029,10 +1029,8 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
 	struct dma_device *dma_dev;
 
 	mv_chan = devm_kzalloc(&pdev->dev, sizeof(*mv_chan), GFP_KERNEL);
-	if (!mv_chan) {
-		ret = -ENOMEM;
-		goto err_free_dma;
-	}
+	if (!mv_chan)
+		return ERR_PTR(-ENOMEM);
 
 	mv_chan->idx = idx;
 	mv_chan->irq = irq;

                 reply	other threads:[~2013-08-22 12:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20130822125839.GC2543@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=devicetree@vger.kernel.org \
    --cc=djbw@fb.com \
    --cc=grant.likely@linaro.org \
    --cc=kernel-janitors@vger.kernel.org \
    --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