linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next][V2] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-04 15:00 Colin King
  2021-02-04 15:45 ` Will Deacon
  2021-02-05  8:50 ` Joerg Roedel
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2021-02-04 15:00 UTC (permalink / raw)
  To: Joerg Roedel, Will Deacon, Matthias Brugger, iommu,
	linux-arm-kernel, linux-mediatek
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently the check for domid < 0 is always false because domid
is unsigned. Fix this by casting domid to an int before making
the comparison.

Addresses-Coverity: ("Unsigned comparison against 0")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---

V2: cast domid rather than making it an int. Replace L with : in
    the commit message.

---
 drivers/iommu/mtk_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index 0ad14a7604b1..1f262621ef19 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -645,7 +645,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
 	struct iommu_resv_region *region;
 	int prot = IOMMU_WRITE | IOMMU_READ;
 
-	if (domid < 0)
+	if ((int)domid < 0)
 		return;
 	curdom = data->plat_data->iova_region + domid;
 	for (i = 0; i < data->plat_data->iova_region_nr; i++) {
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][next][V2] iommu/mediatek: Fix unsigned domid comparison with less than zero
  2021-02-04 15:00 [PATCH][next][V2] iommu/mediatek: Fix unsigned domid comparison with less than zero Colin King
@ 2021-02-04 15:45 ` Will Deacon
  2021-02-05  8:50 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Will Deacon @ 2021-02-04 15:45 UTC (permalink / raw)
  To: Colin King
  Cc: Joerg Roedel, Matthias Brugger, iommu, linux-arm-kernel,
	linux-mediatek, kernel-janitors, linux-kernel

On Thu, Feb 04, 2021 at 03:00:01PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the check for domid < 0 is always false because domid
> is unsigned. Fix this by casting domid to an int before making
> the comparison.
> 
> Addresses-Coverity: ("Unsigned comparison against 0")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> 
> V2: cast domid rather than making it an int. Replace L with : in
>     the commit message.
> 
> ---
>  drivers/iommu/mtk_iommu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> index 0ad14a7604b1..1f262621ef19 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -645,7 +645,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
>  	struct iommu_resv_region *region;
>  	int prot = IOMMU_WRITE | IOMMU_READ;
>  
> -	if (domid < 0)
> +	if ((int)domid < 0)
>  		return;
>  	curdom = data->plat_data->iova_region + domid;
>  	for (i = 0; i < data->plat_data->iova_region_nr; i++) {

Thanks, Colin.

Acked-by: Will Deacon <will@kernel.org>

Will

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][next][V2] iommu/mediatek: Fix unsigned domid comparison with less than zero
  2021-02-04 15:00 [PATCH][next][V2] iommu/mediatek: Fix unsigned domid comparison with less than zero Colin King
  2021-02-04 15:45 ` Will Deacon
@ 2021-02-05  8:50 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2021-02-05  8:50 UTC (permalink / raw)
  To: Colin King
  Cc: Will Deacon, Matthias Brugger, iommu, linux-arm-kernel,
	linux-mediatek, kernel-janitors, linux-kernel

On Thu, Feb 04, 2021 at 03:00:01PM +0000, Colin King wrote:
>  drivers/iommu/mtk_iommu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-05  8:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-04 15:00 [PATCH][next][V2] iommu/mediatek: Fix unsigned domid comparison with less than zero Colin King
2021-02-04 15:45 ` Will Deacon
2021-02-05  8:50 ` Joerg Roedel

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).