Commit 87d62d8f authored by Junlin Yang's avatar Junlin Yang Committed by Mark Brown

spi: cadence-quadspi: add missing of_node_put

Fix OF node leaks by calling of_node_put in
for_each_available_child_of_node when the cycle returns.

Generated by: scripts/coccinelle/iterators/for_each_child.cocci
Signed-off-by: default avatarJunlin Yang <yangjunlin@yulong.com>
Link: https://lore.kernel.org/r/20210215110425.1012-1-angkery@163.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 120a9e81
...@@ -1389,11 +1389,13 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi) ...@@ -1389,11 +1389,13 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi)
ret = of_property_read_u32(np, "reg", &cs); ret = of_property_read_u32(np, "reg", &cs);
if (ret) { if (ret) {
dev_err(dev, "Couldn't determine chip select.\n"); dev_err(dev, "Couldn't determine chip select.\n");
of_node_put(np);
return ret; return ret;
} }
if (cs >= CQSPI_MAX_CHIPSELECT) { if (cs >= CQSPI_MAX_CHIPSELECT) {
dev_err(dev, "Chip select %d out of range.\n", cs); dev_err(dev, "Chip select %d out of range.\n", cs);
of_node_put(np);
return -EINVAL; return -EINVAL;
} }
...@@ -1402,8 +1404,10 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi) ...@@ -1402,8 +1404,10 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi)
f_pdata->cs = cs; f_pdata->cs = cs;
ret = cqspi_of_get_flash_pdata(pdev, f_pdata, np); ret = cqspi_of_get_flash_pdata(pdev, f_pdata, np);
if (ret) if (ret) {
of_node_put(np);
return ret; return ret;
}
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment