iio: adc: gyroadc: fix leak of device node iterator
commit5.4-rM2-2.2.x-imx-squashedda4410d407
upstream. Add missing of_node_put calls when exiting the for_each_child_of_node loop in rcar_gyroadc_parse_subdevs early. Also add goto-exception handling for the error paths in that loop. Fixes:059c53b323
("iio: adc: Add Renesas GyroADC driver") Signed-off-by: Tobias Jordan <kernel@cdqe.de> Link: https://lore.kernel.org/r/20200926161946.GA10240@agrajag.zerfleddert.de Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
parent
ad877be5b9
commit
a8c59abdbc
|
@ -357,7 +357,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
|
||||||
num_channels = ARRAY_SIZE(rcar_gyroadc_iio_channels_3);
|
num_channels = ARRAY_SIZE(rcar_gyroadc_iio_channels_3);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
goto err_e_inval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -374,7 +374,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
|
||||||
dev_err(dev,
|
dev_err(dev,
|
||||||
"Failed to get child reg property of ADC \"%pOFn\".\n",
|
"Failed to get child reg property of ADC \"%pOFn\".\n",
|
||||||
child);
|
child);
|
||||||
return ret;
|
goto err_of_node_put;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Channel number is too high. */
|
/* Channel number is too high. */
|
||||||
|
@ -382,7 +382,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
|
||||||
dev_err(dev,
|
dev_err(dev,
|
||||||
"Only %i channels supported with %pOFn, but reg = <%i>.\n",
|
"Only %i channels supported with %pOFn, but reg = <%i>.\n",
|
||||||
num_channels, child, reg);
|
num_channels, child, reg);
|
||||||
return -EINVAL;
|
goto err_e_inval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
|
||||||
dev_err(dev,
|
dev_err(dev,
|
||||||
"Channel %i uses different ADC mode than the rest.\n",
|
"Channel %i uses different ADC mode than the rest.\n",
|
||||||
reg);
|
reg);
|
||||||
return -EINVAL;
|
goto err_e_inval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Channel is valid, grab the regulator. */
|
/* Channel is valid, grab the regulator. */
|
||||||
|
@ -401,7 +401,8 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
|
||||||
if (IS_ERR(vref)) {
|
if (IS_ERR(vref)) {
|
||||||
dev_dbg(dev, "Channel %i 'vref' supply not connected.\n",
|
dev_dbg(dev, "Channel %i 'vref' supply not connected.\n",
|
||||||
reg);
|
reg);
|
||||||
return PTR_ERR(vref);
|
ret = PTR_ERR(vref);
|
||||||
|
goto err_of_node_put;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->vref[reg] = vref;
|
priv->vref[reg] = vref;
|
||||||
|
@ -425,8 +426,10 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
|
||||||
* attached to the GyroADC at a time, so if we found it,
|
* attached to the GyroADC at a time, so if we found it,
|
||||||
* we can stop parsing here.
|
* we can stop parsing here.
|
||||||
*/
|
*/
|
||||||
if (childmode == RCAR_GYROADC_MODE_SELECT_1_MB88101A)
|
if (childmode == RCAR_GYROADC_MODE_SELECT_1_MB88101A) {
|
||||||
|
of_node_put(child);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
|
@ -435,6 +438,12 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err_e_inval:
|
||||||
|
ret = -EINVAL;
|
||||||
|
err_of_node_put:
|
||||||
|
of_node_put(child);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rcar_gyroadc_deinit_supplies(struct iio_dev *indio_dev)
|
static void rcar_gyroadc_deinit_supplies(struct iio_dev *indio_dev)
|
||||||
|
|
Loading…
Reference in New Issue