linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Vyacheslav V. Yurkov" <uvv.mail@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
	"Vyacheslav V. Yurkov" <uvv.mail@gmail.com>
Subject: [PATCH] [RESEND] drivers/base dmam_declare_coherent_memory leaks
Date: Tue, 14 Jun 2016 09:58:37 +0200	[thread overview]
Message-ID: <1465891117-18215-1-git-send-email-uvv.mail@gmail.com> (raw)
In-Reply-To: <5722283C.60209@gmail.com>

dmam_declare_coherent_memory doesn't take into account the return
value of dma_declare_coherent_memory, which leads to incorrect resource
handling

Signed-off-by: Vyacheslav V. Yurkov <uvv.mail@gmail.com>
---
 drivers/base/dma-mapping.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index d799662..f5d2132 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -198,10 +198,13 @@ int dmam_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
 
 	rc = dma_declare_coherent_memory(dev, phys_addr, device_addr, size,
 					 flags);
-	if (rc == 0)
+	if (rc) {
 		devres_add(dev, res);
-	else
+		rc = 0;
+	} else {
 		devres_free(res);
+		rc = -ENOMEM;
+	}
 
 	return rc;
 }
-- 
1.8.4

      reply	other threads:[~2016-06-14  7:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-28 14:31 [PATCH] drivers/base: wrong return value of dmam_declare_coherent_memory Andrey Gursky
2016-04-28 15:11 ` Vyacheslav Yurkov
2016-06-14  7:58   ` Vyacheslav V. Yurkov [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=1465891117-18215-1-git-send-email-uvv.mail@gmail.com \
    --to=uvv.mail@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.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;
as well as URLs for NNTP newsgroup(s).