From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Ekansh Gupta <quic_ekangupt@quicinc.com>, linux-arm-msm@vger.kernel.org
Cc: ekangupt@qti.qualcomm.com, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org, fastrpc.upstream@qti.qualcomm.com,
stable <stable@kernel.org>
Subject: Re: [PATCH v3] misc: fastrpc: Fix incorrect DMA mapping unmap request
Date: Wed, 2 Aug 2023 14:43:26 +0100 [thread overview]
Message-ID: <4059684f-2e44-ccd6-4c65-5137cc76492c@linaro.org> (raw)
In-Reply-To: <1690953032-17070-1-git-send-email-quic_ekangupt@quicinc.com>
On 02/08/2023 06:10, Ekansh Gupta wrote:
> Scatterlist table is obtained during map create request and the same
> table is used for DMA mapping unmap. In case there is any failure
> while getting the sg_table, ERR_PTR is returned instead of sg_table.
>
> When the map is getting freed, there is only a non-NULL check of
> sg_table which will also be true in case failure was returned instead
> of sg_table. This would result in improper unmap request. Add proper
> check before setting map table to avoid bad unmap request.
>
> Fixes: c68cfb718c8f ("misc: fastrpc: Add support for context Invoke method")
> Cc: stable <stable@kernel.org>
> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
> ---
> Changes in v2:
> - Added fixes information to commit text
> Changes in v3:
> - Set map->table only if attachment for successful
>
> drivers/misc/fastrpc.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 9666d28..de7c812 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -756,6 +756,7 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
> {
> struct fastrpc_session_ctx *sess = fl->sctx;
> struct fastrpc_map *map = NULL;
> + struct sg_table *table;
> int err = 0;
>
> if (!fastrpc_map_lookup(fl, fd, ppmap, true))
> @@ -783,11 +784,12 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
> goto attach_err;
> }
>
> - map->table = dma_buf_map_attachment_unlocked(map->attach, DMA_BIDIRECTIONAL);
> - if (IS_ERR(map->table)) {
> - err = PTR_ERR(map->table);
> + table = dma_buf_map_attachment(map->attach, DMA_BIDIRECTIONAL);
Any reason why dma_buf_map_attachment_unlocked changed to
dma_buf_map_attachment?
--srini
> + if (IS_ERR(table)) {
> + err = PTR_ERR(table);
> goto map_err;
> }
> + map->table = table;
>
> if (attr & FASTRPC_ATTR_SECUREMAP) {
> map->phys = sg_phys(map->table->sgl);
next prev parent reply other threads:[~2023-08-02 13:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 5:10 Ekansh Gupta
2023-08-02 13:43 ` Srinivas Kandagatla [this message]
2023-08-02 13:49 ` Ekansh Gupta
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=4059684f-2e44-ccd6-4c65-5137cc76492c@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=ekangupt@qti.qualcomm.com \
--cc=fastrpc.upstream@qti.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_ekangupt@quicinc.com \
--cc=stable@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
all inboxes | Powered by JetHome®