From: Miles Chen via iommu <iommu@lists.linux-foundation.org>
To: <yf.wang@mediatek.com>
Cc: wsd_upstream@mediatek.com, will@kernel.org,
linux-kernel@vger.kernel.org, Libo.Kang@mediatek.com,
iommu@lists.linux-foundation.org,
linux-mediatek@lists.infradead.org, Ning.Li@mediatek.com,
matthias.bgg@gmail.com, stable@vger.kernel.org,
logang@deltatee.com, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] iommu/dma: Fix iova map result check bug
Date: Mon, 9 May 2022 00:01:15 +0800 [thread overview]
Message-ID: <20220508160115.4851-1-miles.chen@mediatek.com> (raw)
In-Reply-To: <20220507085204.16914-1-yf.wang@mediatek.com>
> The data type of the return value of the iommu_map_sg_atomic
> is ssize_t, but the data type of iova size is size_t,
> e.g. one is int while the other is unsigned int.
>
> When iommu_map_sg_atomic return value is compared with iova size,
> it will force the signed int to be converted to unsigned int, if
> iova map fails and iommu_map_sg_atomic return error code is less
> than 0, then (ret < iova_len) is false, which will to cause not
> do free iova, and the master can still successfully get the iova
> of map fail, which is not expected.
>
> Therefore, we need to check the return value of iommu_map_sg_atomic
> in two cases according to whether it is less than 0.
>
> Fixes: ad8f36e4b6b1 ("iommu: return full error code from iommu_map_sg[_atomic]()")
> Signed-off-by: Yunfei Wang <yf.wang@mediatek.com>
Yes, we have to make sure ssize_t >= 0 before comparing ssize_t and size_t.
Reviewed-by: Miles Chen <miles.chen@mediatek.com>
>
> Cc: <stable@vger.kernel.org> # 5.15.*
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2022-05-08 16:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-07 8:52 [PATCH] iommu/dma: Fix iova map result check bug yf.wang--- via iommu
2022-05-08 16:01 ` Miles Chen via iommu [this message]
2022-05-09 9:22 ` Robin Murphy
2022-05-12 5:51 ` Yong Wu via iommu
2022-05-13 13:01 ` Joerg Roedel
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=20220508160115.4851-1-miles.chen@mediatek.com \
--to=iommu@lists.linux-foundation.org \
--cc=Libo.Kang@mediatek.com \
--cc=Ning.Li@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=logang@deltatee.com \
--cc=matthias.bgg@gmail.com \
--cc=miles.chen@mediatek.com \
--cc=stable@vger.kernel.org \
--cc=will@kernel.org \
--cc=wsd_upstream@mediatek.com \
--cc=yf.wang@mediatek.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