Skip to content

Commit 3a2390c

Browse files
Hui TangpH5
authored andcommitted
reset: uniphier-glue: Fix possible null-ptr-deref
It will cause null-ptr-deref when resource_size(res) invoked, if platform_get_resource() returns NULL. Fixes: 499fef0 ("reset: uniphier: add USB3 core reset control") Signed-off-by: Hui Tang <[email protected]> Reviewed-by: Kunihiko Hayashi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Philipp Zabel <[email protected]>
1 parent 13678f3 commit 3a2390c

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/reset/reset-uniphier-glue.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ static int uniphier_glue_reset_probe(struct platform_device *pdev)
4747
struct device *dev = &pdev->dev;
4848
struct uniphier_glue_reset_priv *priv;
4949
struct resource *res;
50-
resource_size_t size;
5150
int i, ret;
5251

5352
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -60,7 +59,6 @@ static int uniphier_glue_reset_probe(struct platform_device *pdev)
6059
return -EINVAL;
6160

6261
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
63-
size = resource_size(res);
6462
priv->rdata.membase = devm_ioremap_resource(dev, res);
6563
if (IS_ERR(priv->rdata.membase))
6664
return PTR_ERR(priv->rdata.membase);
@@ -96,7 +94,7 @@ static int uniphier_glue_reset_probe(struct platform_device *pdev)
9694

9795
spin_lock_init(&priv->rdata.lock);
9896
priv->rdata.rcdev.owner = THIS_MODULE;
99-
priv->rdata.rcdev.nr_resets = size * BITS_PER_BYTE;
97+
priv->rdata.rcdev.nr_resets = resource_size(res) * BITS_PER_BYTE;
10098
priv->rdata.rcdev.ops = &reset_simple_ops;
10199
priv->rdata.rcdev.of_node = dev->of_node;
102100
priv->rdata.active_low = true;

0 commit comments

Comments
 (0)