* [PATCH] drm/ingenic: Use resource_size function on resource object
@ 2022-03-03 8:08 Jiapeng Chong
0 siblings, 0 replies; 4+ messages in thread
From: Jiapeng Chong @ 2022-03-03 8:08 UTC (permalink / raw)
To: paul
Cc: Jiapeng Chong, airlied, Abaci Robot, linux-mips, dri-devel, linux-kernel
Clean up the following coccicheck warning:
./drivers/gpu/drm/ingenic/ingenic-drm-drv.c:1110:35-38: WARNING:
Suspicious code. resource_size is maybe missing with res.
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
index ac52b49bf901..52ad5cab64bb 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
@@ -1107,7 +1107,7 @@ static int ingenic_drm_bind(struct device *dev, bool has_components)
}
regmap_config = ingenic_drm_regmap_config;
- regmap_config.max_register = res->end - res->start;
+ regmap_config.max_register = resource_size(res);
priv->map = devm_regmap_init_mmio(dev, base,
®map_config);
if (IS_ERR(priv->map)) {
--
2.20.1.7.g153144c
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/ingenic: Use resource_size function on resource object
2022-06-24 1:31 Jiapeng Chong
2022-06-24 17:25 ` Sam Ravnborg
@ 2022-06-24 19:00 ` Paul Cercueil
1 sibling, 0 replies; 4+ messages in thread
From: Paul Cercueil @ 2022-06-24 19:00 UTC (permalink / raw)
To: Jiapeng Chong; +Cc: airlied, linux-mips, dri-devel, linux-kernel, Sam Ravnborg
Hi,
Le ven., juin 24 2022 at 09:31:59 +0800, Jiapeng Chong
<jiapeng.chong@linux.alibaba.com> a écrit :
> This was found by coccicheck:
>
> ./drivers/gpu/drm/ingenic/ingenic-drm-drv.c:1149:35-38: WARNING:
> Suspicious code. resource_size is maybe missing with res.
>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
> drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> index 2c559885347a..5514b163999f 100644
> --- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> +++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> @@ -1146,7 +1146,7 @@ static int ingenic_drm_bind(struct device *dev,
> bool has_components)
> }
>
> regmap_config = ingenic_drm_regmap_config;
> - regmap_config.max_register = res->end - res->start;
> + regmap_config.max_register = resource_size(res);
These two are not equivalent. resource_size() is (res->end - res->start
+ 1).
If the memory resource has a size of 0x10 bytes, then using
resource_size() will set .max_register == 0x10, which is invalid, as it
is already outside the memory resource.
Cheers,
-Paul
> priv->map = devm_regmap_init_mmio(dev, base,
> ®map_config);
> if (IS_ERR(priv->map)) {
> --
> 2.20.1.7.g153144c
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/ingenic: Use resource_size function on resource object
2022-06-24 1:31 Jiapeng Chong
@ 2022-06-24 17:25 ` Sam Ravnborg
2022-06-24 19:00 ` Paul Cercueil
1 sibling, 0 replies; 4+ messages in thread
From: Sam Ravnborg @ 2022-06-24 17:25 UTC (permalink / raw)
To: Jiapeng Chong; +Cc: paul, airlied, linux-mips, dri-devel, linux-kernel
Hi Jiapeng,
On Fri, Jun 24, 2022 at 09:31:59AM +0800, Jiapeng Chong wrote:
> This was found by coccicheck:
>
> ./drivers/gpu/drm/ingenic/ingenic-drm-drv.c:1149:35-38: WARNING: Suspicious code. resource_size is maybe missing with res.
>
Nice one, now I have to go back and fix my code as well.
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] drm/ingenic: Use resource_size function on resource object
@ 2022-06-24 1:31 Jiapeng Chong
2022-06-24 17:25 ` Sam Ravnborg
2022-06-24 19:00 ` Paul Cercueil
0 siblings, 2 replies; 4+ messages in thread
From: Jiapeng Chong @ 2022-06-24 1:31 UTC (permalink / raw)
To: paul; +Cc: Jiapeng Chong, airlied, linux-mips, dri-devel, linux-kernel
This was found by coccicheck:
./drivers/gpu/drm/ingenic/ingenic-drm-drv.c:1149:35-38: WARNING: Suspicious code. resource_size is maybe missing with res.
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
index 2c559885347a..5514b163999f 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
@@ -1146,7 +1146,7 @@ static int ingenic_drm_bind(struct device *dev, bool has_components)
}
regmap_config = ingenic_drm_regmap_config;
- regmap_config.max_register = res->end - res->start;
+ regmap_config.max_register = resource_size(res);
priv->map = devm_regmap_init_mmio(dev, base,
®map_config);
if (IS_ERR(priv->map)) {
--
2.20.1.7.g153144c
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-06-24 19:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-03 8:08 [PATCH] drm/ingenic: Use resource_size function on resource object Jiapeng Chong
2022-06-24 1:31 Jiapeng Chong
2022-06-24 17:25 ` Sam Ravnborg
2022-06-24 19:00 ` Paul Cercueil
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).