From: Vyacheslav Yurkov <uvv.mail@gmail.com>
To: Andrey Gursky <andrey.gursky@e-mail.ua>
Cc: linux-kernel@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH] drivers/base: wrong return value of dmam_declare_coherent_memory
Date: Thu, 28 Apr 2016 17:11:56 +0200 [thread overview]
Message-ID: <5722283C.60209@gmail.com> (raw)
In-Reply-To: <20160428163128.2670db58033e598779e373f6@e-mail.ua>
On 28.04.2016 16:31, Andrey Gursky wrote:
> Vyacheslav,
>
> thanks for your patch.
>
> For now it introduces a new bug.
>
> Vyacheslav Yurkov <uvv.mail <at> gmail.com> writes:
>
>>
>> Hi guys,
>> I found an issue in managed version of dma_declare_coherent_memory,
>> i.e. in dmam_declare_coherent_memory. It looks like the return value
>> of dma_declare_coherent_memory is zero in case of error and a
>> requested flag on success,
>
> You should take this into account and not ignore the value of rc at all
> by using flags instead, which is not being altered by
> dma_declare_coherent_memory() making the latter appear to succeed
> always.
>
>
Hi Andrey,
Thanks for spotting this. My intention was to compare rc of course,
not the flags. While thinking it over I came up with improved version,
which is inlined below.
---
Yours sincerely,
Vyacheslav V. Yurkov
P.S.: I'm not subscribed to the maillist, so please include me in CC
when responding to this Email.
---
--- linux-4.5.2/drivers/base/dma-mapping.c.orig 2016-04-20 08:46:35.000000000 +0200
+++ linux-4.5.2/drivers/base/dma-mapping.c 2016-04-28 16:55:13.211945276 +0200
@@ -198,10 +198,14 @@ int dmam_declare_coherent_memory(struct
rc = dma_declare_coherent_memory(dev, phys_addr, device_addr, size,
flags);
- if (rc == 0)
+
+ if ((rc & (DMA_MEMORY_MAP | DMA_MEMORY_IO)) != 0) {
devres_add(dev, res);
- else
+ rc = 0;
+ } else {
devres_free(res);
+ rc = -ENOMEM;
+ }
return rc;
}
Signed-off-by: Vyacheslav Yurkov <uvv.mail@gmail.com>
next prev parent reply other threads:[~2016-04-28 15:12 UTC|newest]
Thread overview: 4+ 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 [this message]
2016-06-14 7:58 ` [PATCH] [RESEND] drivers/base dmam_declare_coherent_memory leaks Vyacheslav V. Yurkov
-- strict thread matches above, loose matches on Subject: below --
2016-04-28 11:28 [PATCH] drivers/base: wrong return value of dmam_declare_coherent_memory Vyacheslav Yurkov
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=5722283C.60209@gmail.com \
--to=uvv.mail@gmail.com \
--cc=andrey.gursky@e-mail.ua \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.