From: Geert Uytterhoeven Date: Wed, 20 Nov 2019 14:59:26 +0000 (+0100) Subject: reset: Do not register resource data for missing resets X-Git-Tag: Ubuntu-5.4.0-17.21~2054 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=3d0336dd16cdb2b30bb18c25b706cbce79fac904;p=mirror_ubuntu-focal-kernel.git reset: Do not register resource data for missing resets BugLink: https://bugs.launchpad.net/bugs/1860130 [ Upstream commit db23808615e29d9a04f96806cac56f78b0fee0ef ] When an optional reset is not present, __devm_reset_control_get() and devm_reset_control_array_get() still register resource data to release the non-existing reset on cleanup, which is futile. Fix this by skipping NULL reset control pointers. Signed-off-by: Geert Uytterhoeven Signed-off-by: Philipp Zabel Signed-off-by: Sasha Levin Signed-off-by: Paolo Pisati --- diff --git a/drivers/reset/core.c b/drivers/reset/core.c index 3c9a64c1b7a8..f343bd814d32 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -787,7 +787,7 @@ struct reset_control *__devm_reset_control_get(struct device *dev, return ERR_PTR(-ENOMEM); rstc = __reset_control_get(dev, id, index, shared, optional, acquired); - if (!IS_ERR(rstc)) { + if (!IS_ERR_OR_NULL(rstc)) { *ptr = rstc; devres_add(dev, ptr); } else { @@ -930,7 +930,7 @@ devm_reset_control_array_get(struct device *dev, bool shared, bool optional) return ERR_PTR(-ENOMEM); rstc = of_reset_control_array_get(dev->of_node, shared, optional, true); - if (IS_ERR(rstc)) { + if (IS_ERR_OR_NULL(rstc)) { devres_free(devres); return rstc; }