Skip to content

Commit a827a49

Browse files
larsclausenjic23
authored andcommitted
iio: trigger: Fix reference counting
In viio_trigger_alloc() device_initialize() is used to set the initial reference count of the trigger to 1. Then another get_device() is called on trigger. This sets the reference count to 2 before the trigger is returned. iio_trigger_free(), which is the matching API to viio_trigger_alloc(), calls put_device() which decreases the reference count by 1. But the second reference count acquired in viio_trigger_alloc() is never dropped. As a result the iio_trigger_release() function is never called and the memory associated with the trigger is never freed. Since there is no reason for the trigger to start its lifetime with two reference counts just remove the extra get_device() in viio_trigger_alloc(). Fixes: 5f9c035 ("staging:iio:triggers. Add a reference get to the core for triggers.") Signed-off-by: Lars-Peter Clausen <[email protected]> Acked-by: Nuno Sá <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 59f9286 commit a827a49

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

drivers/iio/industrialio-trigger.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,6 @@ struct iio_trigger *viio_trigger_alloc(struct device *parent,
556556
irq_modify_status(trig->subirq_base + i,
557557
IRQ_NOREQUEST | IRQ_NOAUTOEN, IRQ_NOPROBE);
558558
}
559-
get_device(&trig->dev);
560559

561560
return trig;
562561

0 commit comments

Comments
 (0)