Skip to content

Commit 65f2030

Browse files
Yang Yingliangjic23
authored andcommitted
iio: adc: at91_adc: fix possible memory leak in at91_adc_allocate_trigger()
If iio_trigger_register() returns error, it should call iio_trigger_free() to give up the reference that hold in iio_trigger_alloc(), so that it can call iio_trig_release() to free memory when the refcount hit to 0. Fixes: 0e589d5 ("ARM: AT91: IIO: Add AT91 ADC driver.") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Link: https://lore.kernel.org/r/20221024084511.815096-1-yangyingliang@huawei.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent ca1547a commit 65f2030

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/iio/adc/at91_adc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,10 @@ static struct iio_trigger *at91_adc_allocate_trigger(struct iio_dev *idev,
634634
trig->ops = &at91_adc_trigger_ops;
635635

636636
ret = iio_trigger_register(trig);
637-
if (ret)
637+
if (ret) {
638+
iio_trigger_free(trig);
638639
return NULL;
640+
}
639641

640642
return trig;
641643
}

0 commit comments

Comments
 (0)