Skip to content

Commit 079822d

Browse files
AlisonSchofieldgregkh
authored andcommitted
iio: trigger: free trigger resource correctly
[ Upstream commit 10e840dfb0b7fc345082dd9e5fff3c1c02e7690e ] 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 <amsfield22@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 26fa336 commit 079822d

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
@@ -259,7 +259,7 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
259259
out1:
260260
iio_trigger_unregister(st->trig);
261261
out:
262-
iio_trigger_put(st->trig);
262+
iio_trigger_free(st->trig);
263263
return ret;
264264
}
265265

@@ -272,7 +272,7 @@ static int iio_bfin_tmr_trigger_remove(struct platform_device *pdev)
272272
peripheral_free(st->t->pin);
273273
free_irq(st->irq, st);
274274
iio_trigger_unregister(st->trig);
275-
iio_trigger_put(st->trig);
275+
iio_trigger_free(st->trig);
276276

277277
return 0;
278278
}

0 commit comments

Comments
 (0)