* [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-03 13:59 ` Colin King
0 siblings, 0 replies; 30+ messages in thread
From: Colin King @ 2021-02-03 13:59 UTC (permalink / raw)
To: Joerg Roedel, Will Deacon, Matthias Brugger, Anan sun, Yong Wu,
Chao Hao, Tomasz Figa, 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 making it signed.
Addresses-CoverityL ("Unsigned comparison against 0")
Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
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..823d719945b2 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
struct list_head *head)
{
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
- unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
+ int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
const struct mtk_iommu_iova_region *resv, *curdom;
struct iommu_resv_region *region;
int prot = IOMMU_WRITE | IOMMU_READ;
--
2.29.2
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-03 13:59 ` Colin King
0 siblings, 0 replies; 30+ messages in thread
From: Colin King @ 2021-02-03 13:59 UTC (permalink / raw)
To: Joerg Roedel, Will Deacon, Matthias Brugger, Anan sun, Yong Wu,
Chao Hao, Tomasz Figa, 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 making it signed.
Addresses-CoverityL ("Unsigned comparison against 0")
Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
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..823d719945b2 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
struct list_head *head)
{
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
- unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
+ int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
const struct mtk_iommu_iova_region *resv, *curdom;
struct iommu_resv_region *region;
int prot = IOMMU_WRITE | IOMMU_READ;
--
2.29.2
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-03 13:59 ` Colin King
0 siblings, 0 replies; 30+ messages in thread
From: Colin King @ 2021-02-03 13:59 UTC (permalink / raw)
To: Joerg Roedel, Will Deacon, Matthias Brugger, Anan sun, Yong Wu,
Chao Hao, Tomasz Figa, 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 making it signed.
Addresses-CoverityL ("Unsigned comparison against 0")
Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
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..823d719945b2 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
struct list_head *head)
{
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
- unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
+ int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
const struct mtk_iommu_iova_region *resv, *curdom;
struct iommu_resv_region *region;
int prot = IOMMU_WRITE | IOMMU_READ;
--
2.29.2
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-03 13:59 ` Colin King
0 siblings, 0 replies; 30+ messages in thread
From: Colin King @ 2021-02-03 13:59 UTC (permalink / raw)
To: Joerg Roedel, Will Deacon, Matthias Brugger, Anan sun, Yong Wu,
Chao Hao, Tomasz Figa, 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 making it signed.
Addresses-CoverityL ("Unsigned comparison against 0")
Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
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..823d719945b2 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
struct list_head *head)
{
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
- unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
+ int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
const struct mtk_iommu_iova_region *resv, *curdom;
struct iommu_resv_region *region;
int prot = IOMMU_WRITE | IOMMU_READ;
--
2.29.2
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-03 13:59 ` Colin King
0 siblings, 0 replies; 30+ messages in thread
From: Colin King @ 2021-02-03 13:59 UTC (permalink / raw)
To: Joerg Roedel, Will Deacon, Matthias Brugger, Anan sun, Yong Wu,
Chao Hao, Tomasz Figa, 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 making it signed.
Addresses-CoverityL ("Unsigned comparison against 0")
Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
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..823d719945b2 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
struct list_head *head)
{
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
- unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
+ int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
const struct mtk_iommu_iova_region *resv, *curdom;
struct iommu_resv_region *region;
int prot = IOMMU_WRITE | IOMMU_READ;
--
2.29.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
2021-02-03 13:59 ` Colin King
` (2 preceding siblings ...)
(?)
@ 2021-02-04 1:11 ` Yong Wu
-1 siblings, 0 replies; 30+ messages in thread
From: Yong Wu @ 2021-02-04 1:11 UTC (permalink / raw)
To: Colin King
Cc: Joerg Roedel, Will Deacon, Matthias Brugger, Anan sun, Chao Hao,
Tomasz Figa, iommu, linux-arm-kernel, linux-mediatek,
kernel-janitors, linux-kernel
On Wed, 2021-02-03 at 13:59 +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 making it signed.
>
> Addresses-CoverityL ("Unsigned comparison against 0")
> Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Thanks for the fix.
Reviewed-by: Yong Wu <yong.wu@mediatek.com>
> ---
> 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..823d719945b2 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> struct list_head *head)
> {
> struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> const struct mtk_iommu_iova_region *resv, *curdom;
> struct iommu_resv_region *region;
> int prot = IOMMU_WRITE | IOMMU_READ;
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-04 1:11 ` Yong Wu
0 siblings, 0 replies; 30+ messages in thread
From: Yong Wu @ 2021-02-04 1:11 UTC (permalink / raw)
To: Colin King
Cc: Anan sun, Joerg Roedel, kernel-janitors, linux-kernel,
Tomasz Figa, Chao Hao, iommu, linux-mediatek, Matthias Brugger,
Will Deacon, linux-arm-kernel
T24gV2VkLCAyMDIxLTAyLTAzIGF0IDEzOjU5ICswMDAwLCBDb2xpbiBLaW5nIHdyb3RlOg0KPiBG
cm9tOiBDb2xpbiBJYW4gS2luZyA8Y29saW4ua2luZ0BjYW5vbmljYWwuY29tPg0KPiANCj4gQ3Vy
cmVudGx5IHRoZSBjaGVjayBmb3IgZG9taWQgPCAwIGlzIGFsd2F5cyBmYWxzZSBiZWNhdXNlIGRv
bWlkDQo+IGlzIHVuc2lnbmVkLiAgRml4IHRoaXMgYnkgbWFraW5nIGl0IHNpZ25lZC4NCj4gDQo+
IEFkZHJlc3Nlcy1Db3Zlcml0eUwgKCJVbnNpZ25lZCBjb21wYXJpc29uIGFnYWluc3QgMCIpDQo+
IEZpeGVzOiBhYjFkNTI4MWE2MmIgKCJpb21tdS9tZWRpYXRlazogQWRkIGlvdmEgcmVzZXJ2ZWQg
ZnVuY3Rpb24iKQ0KPiBTaWduZWQtb2ZmLWJ5OiBDb2xpbiBJYW4gS2luZyA8Y29saW4ua2luZ0Bj
YW5vbmljYWwuY29tPg0KDQpUaGFua3MgZm9yIHRoZSBmaXguDQoNClJldmlld2VkLWJ5OiBZb25n
IFd1IDx5b25nLnd1QG1lZGlhdGVrLmNvbT4NCg0KPiAtLS0NCj4gIGRyaXZlcnMvaW9tbXUvbXRr
X2lvbW11LmMgfCAyICstDQo+ICAxIGZpbGUgY2hhbmdlZCwgMSBpbnNlcnRpb24oKyksIDEgZGVs
ZXRpb24oLSkNCj4gDQo+IGRpZmYgLS1naXQgYS9kcml2ZXJzL2lvbW11L210a19pb21tdS5jIGIv
ZHJpdmVycy9pb21tdS9tdGtfaW9tbXUuYw0KPiBpbmRleCAwYWQxNGE3NjA0YjEuLjgyM2Q3MTk5
NDViMiAxMDA2NDQNCj4gLS0tIGEvZHJpdmVycy9pb21tdS9tdGtfaW9tbXUuYw0KPiArKysgYi9k
cml2ZXJzL2lvbW11L210a19pb21tdS5jDQo+IEBAIC02NDAsNyArNjQwLDcgQEAgc3RhdGljIHZv
aWQgbXRrX2lvbW11X2dldF9yZXN2X3JlZ2lvbnMoc3RydWN0IGRldmljZSAqZGV2LA0KPiAgCQkJ
CSAgICAgICBzdHJ1Y3QgbGlzdF9oZWFkICpoZWFkKQ0KPiAgew0KPiAgCXN0cnVjdCBtdGtfaW9t
bXVfZGF0YSAqZGF0YSA9IGRldl9pb21tdV9wcml2X2dldChkZXYpOw0KPiAtCXVuc2lnbmVkIGlu
dCBkb21pZCA9IG10a19pb21tdV9nZXRfZG9tYWluX2lkKGRldiwgZGF0YS0+cGxhdF9kYXRhKSwg
aTsNCj4gKwlpbnQgZG9taWQgPSBtdGtfaW9tbXVfZ2V0X2RvbWFpbl9pZChkZXYsIGRhdGEtPnBs
YXRfZGF0YSksIGk7DQo+ICAJY29uc3Qgc3RydWN0IG10a19pb21tdV9pb3ZhX3JlZ2lvbiAqcmVz
diwgKmN1cmRvbTsNCj4gIAlzdHJ1Y3QgaW9tbXVfcmVzdl9yZWdpb24gKnJlZ2lvbjsNCj4gIAlp
bnQgcHJvdCA9IElPTU1VX1dSSVRFIHwgSU9NTVVfUkVBRDsNCg0K
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-04 1:11 ` Yong Wu
0 siblings, 0 replies; 30+ messages in thread
From: Yong Wu @ 2021-02-04 1:11 UTC (permalink / raw)
To: Colin King
Cc: Anan sun, kernel-janitors, linux-kernel, Chao Hao, iommu,
linux-mediatek, Matthias Brugger, Will Deacon, linux-arm-kernel
On Wed, 2021-02-03 at 13:59 +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 making it signed.
>
> Addresses-CoverityL ("Unsigned comparison against 0")
> Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Thanks for the fix.
Reviewed-by: Yong Wu <yong.wu@mediatek.com>
> ---
> 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..823d719945b2 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> struct list_head *head)
> {
> struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> const struct mtk_iommu_iova_region *resv, *curdom;
> struct iommu_resv_region *region;
> int prot = IOMMU_WRITE | IOMMU_READ;
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-04 1:11 ` Yong Wu
0 siblings, 0 replies; 30+ messages in thread
From: Yong Wu @ 2021-02-04 1:11 UTC (permalink / raw)
To: Colin King
Cc: Anan sun, Joerg Roedel, kernel-janitors, linux-kernel,
Tomasz Figa, Chao Hao, iommu, linux-mediatek, Matthias Brugger,
Will Deacon, linux-arm-kernel
On Wed, 2021-02-03 at 13:59 +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 making it signed.
>
> Addresses-CoverityL ("Unsigned comparison against 0")
> Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Thanks for the fix.
Reviewed-by: Yong Wu <yong.wu@mediatek.com>
> ---
> 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..823d719945b2 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> struct list_head *head)
> {
> struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> const struct mtk_iommu_iova_region *resv, *curdom;
> struct iommu_resv_region *region;
> int prot = IOMMU_WRITE | IOMMU_READ;
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-04 1:11 ` Yong Wu
0 siblings, 0 replies; 30+ messages in thread
From: Yong Wu @ 2021-02-04 1:11 UTC (permalink / raw)
To: Colin King
Cc: Anan sun, Joerg Roedel, kernel-janitors, linux-kernel,
Tomasz Figa, Chao Hao, iommu, linux-mediatek, Matthias Brugger,
Will Deacon, linux-arm-kernel
On Wed, 2021-02-03 at 13:59 +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 making it signed.
>
> Addresses-CoverityL ("Unsigned comparison against 0")
> Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Thanks for the fix.
Reviewed-by: Yong Wu <yong.wu@mediatek.com>
> ---
> 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..823d719945b2 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> struct list_head *head)
> {
> struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> const struct mtk_iommu_iova_region *resv, *curdom;
> struct iommu_resv_region *region;
> int prot = IOMMU_WRITE | IOMMU_READ;
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
2021-02-03 13:59 ` Colin King
` (2 preceding siblings ...)
(?)
@ 2021-02-04 9:25 ` Will Deacon
-1 siblings, 0 replies; 30+ messages in thread
From: Will Deacon @ 2021-02-04 9:25 UTC (permalink / raw)
To: Colin King
Cc: Joerg Roedel, Matthias Brugger, Anan sun, Yong Wu, Chao Hao,
Tomasz Figa, iommu, linux-arm-kernel, linux-mediatek,
kernel-janitors, linux-kernel
On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
>
> Addresses-CoverityL ("Unsigned comparison against 0")
Typo here ('L' instead of ':')
> Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> 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..823d719945b2 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> struct list_head *head)
> {
> struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
Not sure if it's intentional, but this also makes 'i' signed. It probably
should remain 'unsigned' to match 'iova_region_nr' in
'struct mtk_iommu_plat_data'.
Will
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-04 9:25 ` Will Deacon
0 siblings, 0 replies; 30+ messages in thread
From: Will Deacon @ 2021-02-04 9:25 UTC (permalink / raw)
To: Colin King
Cc: Anan sun, Joerg Roedel, kernel-janitors, linux-kernel,
Tomasz Figa, Chao Hao, iommu, linux-mediatek, linux-arm-kernel,
Matthias Brugger, Yong Wu
On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
>
> Addresses-CoverityL ("Unsigned comparison against 0")
Typo here ('L' instead of ':')
> Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> 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..823d719945b2 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> struct list_head *head)
> {
> struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
Not sure if it's intentional, but this also makes 'i' signed. It probably
should remain 'unsigned' to match 'iova_region_nr' in
'struct mtk_iommu_plat_data'.
Will
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-04 9:25 ` Will Deacon
0 siblings, 0 replies; 30+ messages in thread
From: Will Deacon @ 2021-02-04 9:25 UTC (permalink / raw)
To: Colin King
Cc: Anan sun, kernel-janitors, linux-kernel, Chao Hao, iommu,
linux-mediatek, linux-arm-kernel, Matthias Brugger
On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
>
> Addresses-CoverityL ("Unsigned comparison against 0")
Typo here ('L' instead of ':')
> Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> 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..823d719945b2 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> struct list_head *head)
> {
> struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
Not sure if it's intentional, but this also makes 'i' signed. It probably
should remain 'unsigned' to match 'iova_region_nr' in
'struct mtk_iommu_plat_data'.
Will
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-04 9:25 ` Will Deacon
0 siblings, 0 replies; 30+ messages in thread
From: Will Deacon @ 2021-02-04 9:25 UTC (permalink / raw)
To: Colin King
Cc: Anan sun, Joerg Roedel, kernel-janitors, linux-kernel,
Tomasz Figa, Chao Hao, iommu, linux-mediatek, linux-arm-kernel,
Matthias Brugger, Yong Wu
On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
>
> Addresses-CoverityL ("Unsigned comparison against 0")
Typo here ('L' instead of ':')
> Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> 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..823d719945b2 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> struct list_head *head)
> {
> struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
Not sure if it's intentional, but this also makes 'i' signed. It probably
should remain 'unsigned' to match 'iova_region_nr' in
'struct mtk_iommu_plat_data'.
Will
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-04 9:25 ` Will Deacon
0 siblings, 0 replies; 30+ messages in thread
From: Will Deacon @ 2021-02-04 9:25 UTC (permalink / raw)
To: Colin King
Cc: Anan sun, Joerg Roedel, kernel-janitors, linux-kernel,
Tomasz Figa, Chao Hao, iommu, linux-mediatek, linux-arm-kernel,
Matthias Brugger, Yong Wu
On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
>
> Addresses-CoverityL ("Unsigned comparison against 0")
Typo here ('L' instead of ':')
> Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> 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..823d719945b2 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> struct list_head *head)
> {
> struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
Not sure if it's intentional, but this also makes 'i' signed. It probably
should remain 'unsigned' to match 'iova_region_nr' in
'struct mtk_iommu_plat_data'.
Will
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
2021-02-04 9:25 ` Will Deacon
` (2 preceding siblings ...)
(?)
@ 2021-02-04 13:31 ` Joerg Roedel
-1 siblings, 0 replies; 30+ messages in thread
From: Joerg Roedel @ 2021-02-04 13:31 UTC (permalink / raw)
To: Will Deacon
Cc: Colin King, Matthias Brugger, Anan sun, Yong Wu, Chao Hao,
Tomasz Figa, iommu, linux-arm-kernel, linux-mediatek,
kernel-janitors, linux-kernel
On Thu, Feb 04, 2021 at 09:25:58AM +0000, Will Deacon wrote:
> On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
> >
> > Addresses-CoverityL ("Unsigned comparison against 0")
>
> Typo here ('L' instead of ':')
>
> > Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > 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..823d719945b2 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> > struct list_head *head)
> > {
> > struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> > - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> > + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
>
> Not sure if it's intentional, but this also makes 'i' signed. It probably
> should remain 'unsigned' to match 'iova_region_nr' in
> 'struct mtk_iommu_plat_data'.
Yes, 'i' should stay unsigned. Colin, can you please fix that up and
re-send?
Thanks,
Joerg
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-04 13:31 ` Joerg Roedel
0 siblings, 0 replies; 30+ messages in thread
From: Joerg Roedel @ 2021-02-04 13:31 UTC (permalink / raw)
To: Will Deacon
Cc: Anan sun, kernel-janitors, linux-kernel, Tomasz Figa, Chao Hao,
iommu, linux-mediatek, linux-arm-kernel, Matthias Brugger,
Colin King, Yong Wu
On Thu, Feb 04, 2021 at 09:25:58AM +0000, Will Deacon wrote:
> On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
> >
> > Addresses-CoverityL ("Unsigned comparison against 0")
>
> Typo here ('L' instead of ':')
>
> > Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > 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..823d719945b2 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> > struct list_head *head)
> > {
> > struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> > - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> > + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
>
> Not sure if it's intentional, but this also makes 'i' signed. It probably
> should remain 'unsigned' to match 'iova_region_nr' in
> 'struct mtk_iommu_plat_data'.
Yes, 'i' should stay unsigned. Colin, can you please fix that up and
re-send?
Thanks,
Joerg
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-04 13:31 ` Joerg Roedel
0 siblings, 0 replies; 30+ messages in thread
From: Joerg Roedel @ 2021-02-04 13:31 UTC (permalink / raw)
To: Will Deacon
Cc: Anan sun, kernel-janitors, linux-kernel, Chao Hao, iommu,
linux-mediatek, linux-arm-kernel, Matthias Brugger, Colin King
On Thu, Feb 04, 2021 at 09:25:58AM +0000, Will Deacon wrote:
> On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
> >
> > Addresses-CoverityL ("Unsigned comparison against 0")
>
> Typo here ('L' instead of ':')
>
> > Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > 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..823d719945b2 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> > struct list_head *head)
> > {
> > struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> > - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> > + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
>
> Not sure if it's intentional, but this also makes 'i' signed. It probably
> should remain 'unsigned' to match 'iova_region_nr' in
> 'struct mtk_iommu_plat_data'.
Yes, 'i' should stay unsigned. Colin, can you please fix that up and
re-send?
Thanks,
Joerg
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-04 13:31 ` Joerg Roedel
0 siblings, 0 replies; 30+ messages in thread
From: Joerg Roedel @ 2021-02-04 13:31 UTC (permalink / raw)
To: Will Deacon
Cc: Anan sun, kernel-janitors, linux-kernel, Tomasz Figa, Chao Hao,
iommu, linux-mediatek, linux-arm-kernel, Matthias Brugger,
Colin King, Yong Wu
On Thu, Feb 04, 2021 at 09:25:58AM +0000, Will Deacon wrote:
> On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
> >
> > Addresses-CoverityL ("Unsigned comparison against 0")
>
> Typo here ('L' instead of ':')
>
> > Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > 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..823d719945b2 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> > struct list_head *head)
> > {
> > struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> > - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> > + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
>
> Not sure if it's intentional, but this also makes 'i' signed. It probably
> should remain 'unsigned' to match 'iova_region_nr' in
> 'struct mtk_iommu_plat_data'.
Yes, 'i' should stay unsigned. Colin, can you please fix that up and
re-send?
Thanks,
Joerg
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-04 13:31 ` Joerg Roedel
0 siblings, 0 replies; 30+ messages in thread
From: Joerg Roedel @ 2021-02-04 13:31 UTC (permalink / raw)
To: Will Deacon
Cc: Anan sun, kernel-janitors, linux-kernel, Tomasz Figa, Chao Hao,
iommu, linux-mediatek, linux-arm-kernel, Matthias Brugger,
Colin King, Yong Wu
On Thu, Feb 04, 2021 at 09:25:58AM +0000, Will Deacon wrote:
> On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
> >
> > Addresses-CoverityL ("Unsigned comparison against 0")
>
> Typo here ('L' instead of ':')
>
> > Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > 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..823d719945b2 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> > struct list_head *head)
> > {
> > struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> > - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> > + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
>
> Not sure if it's intentional, but this also makes 'i' signed. It probably
> should remain 'unsigned' to match 'iova_region_nr' in
> 'struct mtk_iommu_plat_data'.
Yes, 'i' should stay unsigned. Colin, can you please fix that up and
re-send?
Thanks,
Joerg
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
2021-02-04 9:25 ` Will Deacon
` (2 preceding siblings ...)
(?)
@ 2021-02-09 9:19 ` Dan Carpenter
-1 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2021-02-09 9:19 UTC (permalink / raw)
To: Will Deacon
Cc: Colin King, Joerg Roedel, Matthias Brugger, Anan sun, Yong Wu,
Chao Hao, Tomasz Figa, iommu, linux-arm-kernel, linux-mediatek,
kernel-janitors, linux-kernel
On Thu, Feb 04, 2021 at 09:25:58AM +0000, Will Deacon wrote:
> On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
> >
> > Addresses-CoverityL ("Unsigned comparison against 0")
>
> Typo here ('L' instead of ':')
>
> > Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > 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..823d719945b2 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> > struct list_head *head)
> > {
> > struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> > - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> > + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
>
> Not sure if it's intentional, but this also makes 'i' signed. It probably
> should remain 'unsigned' to match 'iova_region_nr' in
> 'struct mtk_iommu_plat_data'.
iova_region_nr is either 1 or 5 so unsigned doesn't matter.
I once almost introduced a bug where the iterator was supposed to be
size_t. I fixed a bug by making it signed but I ended up introducing a
new bug. But generally that's pretty rare. The more common case is
that making iterators unsigned introduces bugs.
It's better to default to "int i;" and if more complicated types are
required that should stand out. "size_t pg_idx;" or whatever.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-09 9:19 ` Dan Carpenter
0 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2021-02-09 9:19 UTC (permalink / raw)
To: Will Deacon
Cc: Anan sun, Joerg Roedel, kernel-janitors, linux-kernel,
Tomasz Figa, Chao Hao, iommu, linux-mediatek, linux-arm-kernel,
Matthias Brugger, Colin King, Yong Wu
On Thu, Feb 04, 2021 at 09:25:58AM +0000, Will Deacon wrote:
> On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
> >
> > Addresses-CoverityL ("Unsigned comparison against 0")
>
> Typo here ('L' instead of ':')
>
> > Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > 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..823d719945b2 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> > struct list_head *head)
> > {
> > struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> > - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> > + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
>
> Not sure if it's intentional, but this also makes 'i' signed. It probably
> should remain 'unsigned' to match 'iova_region_nr' in
> 'struct mtk_iommu_plat_data'.
iova_region_nr is either 1 or 5 so unsigned doesn't matter.
I once almost introduced a bug where the iterator was supposed to be
size_t. I fixed a bug by making it signed but I ended up introducing a
new bug. But generally that's pretty rare. The more common case is
that making iterators unsigned introduces bugs.
It's better to default to "int i;" and if more complicated types are
required that should stand out. "size_t pg_idx;" or whatever.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-09 9:19 ` Dan Carpenter
0 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2021-02-09 9:19 UTC (permalink / raw)
To: Will Deacon
Cc: Anan sun, kernel-janitors, linux-kernel, Chao Hao, iommu,
linux-mediatek, linux-arm-kernel, Matthias Brugger, Colin King
On Thu, Feb 04, 2021 at 09:25:58AM +0000, Will Deacon wrote:
> On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
> >
> > Addresses-CoverityL ("Unsigned comparison against 0")
>
> Typo here ('L' instead of ':')
>
> > Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > 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..823d719945b2 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> > struct list_head *head)
> > {
> > struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> > - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> > + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
>
> Not sure if it's intentional, but this also makes 'i' signed. It probably
> should remain 'unsigned' to match 'iova_region_nr' in
> 'struct mtk_iommu_plat_data'.
iova_region_nr is either 1 or 5 so unsigned doesn't matter.
I once almost introduced a bug where the iterator was supposed to be
size_t. I fixed a bug by making it signed but I ended up introducing a
new bug. But generally that's pretty rare. The more common case is
that making iterators unsigned introduces bugs.
It's better to default to "int i;" and if more complicated types are
required that should stand out. "size_t pg_idx;" or whatever.
regards,
dan carpenter
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-09 9:19 ` Dan Carpenter
0 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2021-02-09 9:19 UTC (permalink / raw)
To: Will Deacon
Cc: Anan sun, Joerg Roedel, kernel-janitors, linux-kernel,
Tomasz Figa, Chao Hao, iommu, linux-mediatek, linux-arm-kernel,
Matthias Brugger, Colin King, Yong Wu
On Thu, Feb 04, 2021 at 09:25:58AM +0000, Will Deacon wrote:
> On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
> >
> > Addresses-CoverityL ("Unsigned comparison against 0")
>
> Typo here ('L' instead of ':')
>
> > Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > 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..823d719945b2 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> > struct list_head *head)
> > {
> > struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> > - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> > + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
>
> Not sure if it's intentional, but this also makes 'i' signed. It probably
> should remain 'unsigned' to match 'iova_region_nr' in
> 'struct mtk_iommu_plat_data'.
iova_region_nr is either 1 or 5 so unsigned doesn't matter.
I once almost introduced a bug where the iterator was supposed to be
size_t. I fixed a bug by making it signed but I ended up introducing a
new bug. But generally that's pretty rare. The more common case is
that making iterators unsigned introduces bugs.
It's better to default to "int i;" and if more complicated types are
required that should stand out. "size_t pg_idx;" or whatever.
regards,
dan carpenter
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-09 9:19 ` Dan Carpenter
0 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2021-02-09 9:19 UTC (permalink / raw)
To: Will Deacon
Cc: Anan sun, Joerg Roedel, kernel-janitors, linux-kernel,
Tomasz Figa, Chao Hao, iommu, linux-mediatek, linux-arm-kernel,
Matthias Brugger, Colin King, Yong Wu
On Thu, Feb 04, 2021 at 09:25:58AM +0000, Will Deacon wrote:
> On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
> >
> > Addresses-CoverityL ("Unsigned comparison against 0")
>
> Typo here ('L' instead of ':')
>
> > Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > 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..823d719945b2 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> > struct list_head *head)
> > {
> > struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> > - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> > + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
>
> Not sure if it's intentional, but this also makes 'i' signed. It probably
> should remain 'unsigned' to match 'iova_region_nr' in
> 'struct mtk_iommu_plat_data'.
iova_region_nr is either 1 or 5 so unsigned doesn't matter.
I once almost introduced a bug where the iterator was supposed to be
size_t. I fixed a bug by making it signed but I ended up introducing a
new bug. But generally that's pretty rare. The more common case is
that making iterators unsigned introduces bugs.
It's better to default to "int i;" and if more complicated types are
required that should stand out. "size_t pg_idx;" or whatever.
regards,
dan carpenter
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 30+ messages in thread
* AW: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
2021-02-09 9:19 ` Dan Carpenter
` (2 preceding siblings ...)
(?)
@ 2021-02-09 10:57 ` Walter Harms
-1 siblings, 0 replies; 30+ messages in thread
From: Walter Harms @ 2021-02-09 10:57 UTC (permalink / raw)
To: Dan Carpenter, Will Deacon
Cc: Colin King, Joerg Roedel, Matthias Brugger, Anan sun, Yong Wu,
Chao Hao, Tomasz Figa, iommu, linux-arm-kernel, linux-mediatek,
kernel-janitors, linux-kernel
I second that ...
Having i unsigned violates the rule of "least surprise".
If you need it unsigned make it clearly visible, also adding
a simple comment may help.
jm2c,
wh
________________________________________
Von: Dan Carpenter <dan.carpenter@oracle.com>
Gesendet: Dienstag, 9. Februar 2021 10:19:23
An: Will Deacon
Cc: Colin King; Joerg Roedel; Matthias Brugger; Anan sun; Yong Wu; Chao Hao; Tomasz Figa; iommu@lists.linux-foundation.org; linux-arm-kernel@lists.infradead.org; linux-mediatek@lists.infradead.org; kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
Betreff: Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
On Thu, Feb 04, 2021 at 09:25:58AM +0000, Will Deacon wrote:
> On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
> >
> > Addresses-CoverityL ("Unsigned comparison against 0")
>
> Typo here ('L' instead of ':')
>
> > Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > 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..823d719945b2 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> > struct list_head *head)
> > {
> > struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> > - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> > + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
>
> Not sure if it's intentional, but this also makes 'i' signed. It probably
> should remain 'unsigned' to match 'iova_region_nr' in
> 'struct mtk_iommu_plat_data'.
iova_region_nr is either 1 or 5 so unsigned doesn't matter.
I once almost introduced a bug where the iterator was supposed to be
size_t. I fixed a bug by making it signed but I ended up introducing a
new bug. But generally that's pretty rare. The more common case is
that making iterators unsigned introduces bugs.
It's better to default to "int i;" and if more complicated types are
required that should stand out. "size_t pg_idx;" or whatever.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 30+ messages in thread
* AW: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-09 10:57 ` Walter Harms
0 siblings, 0 replies; 30+ messages in thread
From: Walter Harms @ 2021-02-09 10:57 UTC (permalink / raw)
To: Dan Carpenter, Will Deacon
Cc: Anan sun, Joerg Roedel, kernel-janitors, linux-kernel,
Tomasz Figa, Chao Hao, iommu, linux-mediatek, linux-arm-kernel,
Matthias Brugger, Colin King, Yong Wu
I second that ...
Having i unsigned violates the rule of "least surprise".
If you need it unsigned make it clearly visible, also adding
a simple comment may help.
jm2c,
wh
________________________________________
Von: Dan Carpenter <dan.carpenter@oracle.com>
Gesendet: Dienstag, 9. Februar 2021 10:19:23
An: Will Deacon
Cc: Colin King; Joerg Roedel; Matthias Brugger; Anan sun; Yong Wu; Chao Hao; Tomasz Figa; iommu@lists.linux-foundation.org; linux-arm-kernel@lists.infradead.org; linux-mediatek@lists.infradead.org; kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
Betreff: Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
On Thu, Feb 04, 2021 at 09:25:58AM +0000, Will Deacon wrote:
> On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
> >
> > Addresses-CoverityL ("Unsigned comparison against 0")
>
> Typo here ('L' instead of ':')
>
> > Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > 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..823d719945b2 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> > struct list_head *head)
> > {
> > struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> > - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> > + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
>
> Not sure if it's intentional, but this also makes 'i' signed. It probably
> should remain 'unsigned' to match 'iova_region_nr' in
> 'struct mtk_iommu_plat_data'.
iova_region_nr is either 1 or 5 so unsigned doesn't matter.
I once almost introduced a bug where the iterator was supposed to be
size_t. I fixed a bug by making it signed but I ended up introducing a
new bug. But generally that's pretty rare. The more common case is
that making iterators unsigned introduces bugs.
It's better to default to "int i;" and if more complicated types are
required that should stand out. "size_t pg_idx;" or whatever.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 30+ messages in thread
* AW: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-09 10:57 ` Walter Harms
0 siblings, 0 replies; 30+ messages in thread
From: Walter Harms @ 2021-02-09 10:57 UTC (permalink / raw)
To: Dan Carpenter, Will Deacon
Cc: Anan sun, kernel-janitors, linux-kernel, Chao Hao, iommu,
linux-mediatek, linux-arm-kernel, Matthias Brugger, Colin King
I second that ...
Having i unsigned violates the rule of "least surprise".
If you need it unsigned make it clearly visible, also adding
a simple comment may help.
jm2c,
wh
________________________________________
Von: Dan Carpenter <dan.carpenter@oracle.com>
Gesendet: Dienstag, 9. Februar 2021 10:19:23
An: Will Deacon
Cc: Colin King; Joerg Roedel; Matthias Brugger; Anan sun; Yong Wu; Chao Hao; Tomasz Figa; iommu@lists.linux-foundation.org; linux-arm-kernel@lists.infradead.org; linux-mediatek@lists.infradead.org; kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
Betreff: Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
On Thu, Feb 04, 2021 at 09:25:58AM +0000, Will Deacon wrote:
> On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
> >
> > Addresses-CoverityL ("Unsigned comparison against 0")
>
> Typo here ('L' instead of ':')
>
> > Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > 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..823d719945b2 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> > struct list_head *head)
> > {
> > struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> > - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> > + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
>
> Not sure if it's intentional, but this also makes 'i' signed. It probably
> should remain 'unsigned' to match 'iova_region_nr' in
> 'struct mtk_iommu_plat_data'.
iova_region_nr is either 1 or 5 so unsigned doesn't matter.
I once almost introduced a bug where the iterator was supposed to be
size_t. I fixed a bug by making it signed but I ended up introducing a
new bug. But generally that's pretty rare. The more common case is
that making iterators unsigned introduces bugs.
It's better to default to "int i;" and if more complicated types are
required that should stand out. "size_t pg_idx;" or whatever.
regards,
dan carpenter
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 30+ messages in thread
* AW: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-09 10:57 ` Walter Harms
0 siblings, 0 replies; 30+ messages in thread
From: Walter Harms @ 2021-02-09 10:57 UTC (permalink / raw)
To: Dan Carpenter, Will Deacon
Cc: Anan sun, Joerg Roedel, kernel-janitors, linux-kernel,
Tomasz Figa, Chao Hao, iommu, linux-mediatek, linux-arm-kernel,
Matthias Brugger, Colin King, Yong Wu
I second that ...
Having i unsigned violates the rule of "least surprise".
If you need it unsigned make it clearly visible, also adding
a simple comment may help.
jm2c,
wh
________________________________________
Von: Dan Carpenter <dan.carpenter@oracle.com>
Gesendet: Dienstag, 9. Februar 2021 10:19:23
An: Will Deacon
Cc: Colin King; Joerg Roedel; Matthias Brugger; Anan sun; Yong Wu; Chao Hao; Tomasz Figa; iommu@lists.linux-foundation.org; linux-arm-kernel@lists.infradead.org; linux-mediatek@lists.infradead.org; kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
Betreff: Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
On Thu, Feb 04, 2021 at 09:25:58AM +0000, Will Deacon wrote:
> On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
> >
> > Addresses-CoverityL ("Unsigned comparison against 0")
>
> Typo here ('L' instead of ':')
>
> > Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > 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..823d719945b2 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> > struct list_head *head)
> > {
> > struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> > - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> > + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
>
> Not sure if it's intentional, but this also makes 'i' signed. It probably
> should remain 'unsigned' to match 'iova_region_nr' in
> 'struct mtk_iommu_plat_data'.
iova_region_nr is either 1 or 5 so unsigned doesn't matter.
I once almost introduced a bug where the iterator was supposed to be
size_t. I fixed a bug by making it signed but I ended up introducing a
new bug. But generally that's pretty rare. The more common case is
that making iterators unsigned introduces bugs.
It's better to default to "int i;" and if more complicated types are
required that should stand out. "size_t pg_idx;" or whatever.
regards,
dan carpenter
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 30+ messages in thread
* AW: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
@ 2021-02-09 10:57 ` Walter Harms
0 siblings, 0 replies; 30+ messages in thread
From: Walter Harms @ 2021-02-09 10:57 UTC (permalink / raw)
To: Dan Carpenter, Will Deacon
Cc: Anan sun, Joerg Roedel, kernel-janitors, linux-kernel,
Tomasz Figa, Chao Hao, iommu, linux-mediatek, linux-arm-kernel,
Matthias Brugger, Colin King, Yong Wu
I second that ...
Having i unsigned violates the rule of "least surprise".
If you need it unsigned make it clearly visible, also adding
a simple comment may help.
jm2c,
wh
________________________________________
Von: Dan Carpenter <dan.carpenter@oracle.com>
Gesendet: Dienstag, 9. Februar 2021 10:19:23
An: Will Deacon
Cc: Colin King; Joerg Roedel; Matthias Brugger; Anan sun; Yong Wu; Chao Hao; Tomasz Figa; iommu@lists.linux-foundation.org; linux-arm-kernel@lists.infradead.org; linux-mediatek@lists.infradead.org; kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
Betreff: Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero
On Thu, Feb 04, 2021 at 09:25:58AM +0000, Will Deacon wrote:
> On Wed, Feb 03, 2021 at 01:59:36PM +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 making it signed.
> >
> > Addresses-CoverityL ("Unsigned comparison against 0")
>
> Typo here ('L' instead of ':')
>
> > Fixes: ab1d5281a62b ("iommu/mediatek: Add iova reserved function")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > 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..823d719945b2 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -640,7 +640,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
> > struct list_head *head)
> > {
> > struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
> > - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
> > + int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i;
>
> Not sure if it's intentional, but this also makes 'i' signed. It probably
> should remain 'unsigned' to match 'iova_region_nr' in
> 'struct mtk_iommu_plat_data'.
iova_region_nr is either 1 or 5 so unsigned doesn't matter.
I once almost introduced a bug where the iterator was supposed to be
size_t. I fixed a bug by making it signed but I ended up introducing a
new bug. But generally that's pretty rare. The more common case is
that making iterators unsigned introduces bugs.
It's better to default to "int i;" and if more complicated types are
required that should stand out. "size_t pg_idx;" or whatever.
regards,
dan carpenter
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2021-02-09 11:05 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 13:59 [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero Colin King
2021-02-03 13:59 ` Colin King
2021-02-03 13:59 ` Colin King
2021-02-03 13:59 ` Colin King
2021-02-03 13:59 ` Colin King
2021-02-04 1:11 ` Yong Wu
2021-02-04 1:11 ` Yong Wu
2021-02-04 1:11 ` Yong Wu
2021-02-04 1:11 ` Yong Wu
2021-02-04 1:11 ` Yong Wu
2021-02-04 9:25 ` Will Deacon
2021-02-04 9:25 ` Will Deacon
2021-02-04 9:25 ` Will Deacon
2021-02-04 9:25 ` Will Deacon
2021-02-04 9:25 ` Will Deacon
2021-02-04 13:31 ` Joerg Roedel
2021-02-04 13:31 ` Joerg Roedel
2021-02-04 13:31 ` Joerg Roedel
2021-02-04 13:31 ` Joerg Roedel
2021-02-04 13:31 ` Joerg Roedel
2021-02-09 9:19 ` Dan Carpenter
2021-02-09 9:19 ` Dan Carpenter
2021-02-09 9:19 ` Dan Carpenter
2021-02-09 9:19 ` Dan Carpenter
2021-02-09 9:19 ` Dan Carpenter
2021-02-09 10:57 ` AW: " Walter Harms
2021-02-09 10:57 ` Walter Harms
2021-02-09 10:57 ` Walter Harms
2021-02-09 10:57 ` Walter Harms
2021-02-09 10:57 ` Walter Harms
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.