drm/ingenic: Use resource_size function on resource object
Subsystems (4)
PATCH 1/1 drm/ingenic: Use resource_size function on resource object
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.
--- drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +1 -1
@@ -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)) {
Signature · 1 line
2.20.1.7.g153144c
Hi Jiapeng,
Quoted 4 lines · Jiapeng Chong
This was found by coccicheck:
./drivers/gpu/drm/ingenic/ingenic-drm-drv.c:1149:35-38: WARNING: Suspicious code.
resource_sizeis maybe missing with res.
Nice one, now I have to go back and fix my code as well.
Quoted 1 line
Signed-off-by Jiapeng Chong <[email protected]>
Paul Cercueil
maintainerHi,
Quoted 14 lines · Jiapeng Chong
This was found by coccicheck:
./drivers/gpu/drm/ingenic/ingenic-drm-drv.c:1149:35-38: WARNING: Suspicious code.
resource_sizeis maybe missing with res.Signed-off-by Jiapeng Chong <[email protected]>--- drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/ingenic/ingenic-drm-drv.c +0
-0
drivers/gpu/drm/ingenic/ingenic-drm-drv.c static int ingenic_drm_bind(struct device *dev, · line 1150
Quoted 6 lines
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +1
-1@@ -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
Quoted 6 lines
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +0
-0priv->map =devm_regmap_init_mmio (dev, base, ®map_config);if (
IS_ERR(priv->map)) {
--
2.20.1.7.g153144c