Skip to content

Commit 10e840d

Browse files
AlisonSchofieldjic23
authored andcommitted
iio: trigger: free trigger resource correctly
These stand-alone trigger drivers were using iio_trigger_put() where they should have been using iio_trigger_free(). The iio_trigger_put() adds a module_put which is bad since they never did a module_get. In the sysfs driver, module_get/put's are used as triggers are added & removed. This extra module_put() occurs on an error path in the probe routine (probably rare). In the bfin-timer & interrupt trigger drivers, the module resources are not explicitly managed, so it's doing a put on something that was never get'd. It occurs on the probe error path and on the remove path (not so rare). Tested with the sysfs trigger driver. The bfin & interrupt drivers were build tested & inspected only. Signed-off-by: Alison Schofield <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 2c99f1a commit 10e840d

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

drivers/iio/trigger/iio-trig-interrupt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static int iio_interrupt_trigger_probe(struct platform_device *pdev)
5858
trig_info = kzalloc(sizeof(*trig_info), GFP_KERNEL);
5959
if (!trig_info) {
6060
ret = -ENOMEM;
61-
goto error_put_trigger;
61+
goto error_free_trigger;
6262
}
6363
iio_trigger_set_drvdata(trig, trig_info);
6464
trig_info->irq = irq;
@@ -83,8 +83,8 @@ static int iio_interrupt_trigger_probe(struct platform_device *pdev)
8383
free_irq(irq, trig);
8484
error_free_trig_info:
8585
kfree(trig_info);
86-
error_put_trigger:
87-
iio_trigger_put(trig);
86+
error_free_trigger:
87+
iio_trigger_free(trig);
8888
error_ret:
8989
return ret;
9090
}
@@ -99,7 +99,7 @@ static int iio_interrupt_trigger_remove(struct platform_device *pdev)
9999
iio_trigger_unregister(trig);
100100
free_irq(trig_info->irq, trig);
101101
kfree(trig_info);
102-
iio_trigger_put(trig);
102+
iio_trigger_free(trig);
103103

104104
return 0;
105105
}

drivers/iio/trigger/iio-trig-sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static int iio_sysfs_trigger_probe(int id)
174174
return 0;
175175

176176
out2:
177-
iio_trigger_put(t->trig);
177+
iio_trigger_free(t->trig);
178178
free_t:
179179
kfree(t);
180180
out1:

drivers/staging/iio/trigger/iio-trig-bfin-timer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
260260
out1:
261261
iio_trigger_unregister(st->trig);
262262
out:
263-
iio_trigger_put(st->trig);
263+
iio_trigger_free(st->trig);
264264
return ret;
265265
}
266266

@@ -273,7 +273,7 @@ static int iio_bfin_tmr_trigger_remove(struct platform_device *pdev)
273273
peripheral_free(st->t->pin);
274274
free_irq(st->irq, st);
275275
iio_trigger_unregister(st->trig);
276-
iio_trigger_put(st->trig);
276+
iio_trigger_free(st->trig);
277277

278278
return 0;
279279
}

0 commit comments

Comments
 (0)