Skip to content

Commit 1aa12ec

Browse files
tititiou36gregkh
authored andcommitted
iio: adc: men_z188_adc: Fix a resource leak in an error handling path
commit e0a2e37 upstream. If iio_device_register() fails, a previous ioremap() is left unbalanced. Update the error handling path and add the missing iounmap() call, as already done in the remove function. Fixes: 74aeac4 ("iio: adc: Add MEN 16z188 ADC driver") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/r/320fc777863880247c2aff4a9d1a54ba69abf080.1643445149.git.christophe.jaillet@wanadoo.fr Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent afbeee1 commit 1aa12ec

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎drivers/iio/adc/men_z188_adc.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ static int men_z188_probe(struct mcb_device *dev,
103103
struct z188_adc *adc;
104104
struct iio_dev *indio_dev;
105105
struct resource *mem;
106+
int ret;
106107

107108
indio_dev = devm_iio_device_alloc(&dev->dev, sizeof(struct z188_adc));
108109
if (!indio_dev)
@@ -128,8 +129,14 @@ static int men_z188_probe(struct mcb_device *dev,
128129
adc->mem = mem;
129130
mcb_set_drvdata(dev, indio_dev);
130131

131-
return iio_device_register(indio_dev);
132+
ret = iio_device_register(indio_dev);
133+
if (ret)
134+
goto err_unmap;
135+
136+
return 0;
132137

138+
err_unmap:
139+
iounmap(adc->base);
133140
err:
134141
mcb_release_mem(mem);
135142
return -ENXIO;

0 commit comments

Comments
 (0)