DMA Engine development
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: vkoul@kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>, dmaengine@vger.kernel.org
Subject: [PATCH] dmaengine: fix incorrect return value for dma_request_chan()
Date: Mon, 06 Jul 2020 08:18:31 -0700	[thread overview]
Message-ID: <159404871194.45151.3076873396834992441.stgit@djiang5-desk3.ch.intel.com> (raw)

dma_request_chan() is expected to return ERR_PTR rather than NULL. This
triggered a crash in pl011_dma_probe() when dma_device_list is empty
and returning NULL. Fix return of NULL ptr to ERR_PTR(-ENODEV).

Fixes: deb9541f5052 ("dmaengine: check device and channel list for empty")
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 drivers/dma/dmaengine.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 0d6529eff66f..48e159e83cf5 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -852,7 +852,7 @@ struct dma_chan *dma_request_chan(struct device *dev, const char *name)
 	mutex_lock(&dma_list_mutex);
 	if (list_empty(&dma_device_list)) {
 		mutex_unlock(&dma_list_mutex);
-		return NULL;
+		return ERR_PTR(-ENODEV);
 	}
 
 	list_for_each_entry_safe(d, _d, &dma_device_list, global_node) {


             reply	other threads:[~2020-07-06 15:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06 15:18 Dave Jiang [this message]
2020-07-06 15:59 ` [PATCH] dmaengine: fix incorrect return value for dma_request_chan() Arnd Bergmann
2020-07-07  5:01 ` Vinod Koul

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=159404871194.45151.3076873396834992441.stgit@djiang5-desk3.ch.intel.com \
    --to=dave.jiang@intel.com \
    --cc=arnd@arndb.de \
    --cc=dmaengine@vger.kernel.org \
    --cc=vkoul@kernel.org \
    /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