]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
iio: trigger: free trigger resource correctly
authorAlison Schofield <amsfield22@gmail.com>
Fri, 20 Jan 2017 03:47:38 +0000 (19:47 -0800)
committerJonathan Cameron <jic23@kernel.org>
Sun, 22 Jan 2017 16:14:21 +0000 (16:14 +0000)
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>
drivers/iio/trigger/iio-trig-interrupt.c
drivers/iio/trigger/iio-trig-sysfs.c
drivers/staging/iio/trigger/iio-trig-bfin-timer.c

index 572bc6f02ca82987a9f3945bc073e4ab835effe9..e18f12b746100c0963c544598081b4cb2828e306 100644 (file)
@@ -58,7 +58,7 @@ static int iio_interrupt_trigger_probe(struct platform_device *pdev)
        trig_info = kzalloc(sizeof(*trig_info), GFP_KERNEL);
        if (!trig_info) {
                ret = -ENOMEM;
-               goto error_put_trigger;
+               goto error_free_trigger;
        }
        iio_trigger_set_drvdata(trig, trig_info);
        trig_info->irq = irq;
@@ -83,8 +83,8 @@ error_release_irq:
        free_irq(irq, trig);
 error_free_trig_info:
        kfree(trig_info);
-error_put_trigger:
-       iio_trigger_put(trig);
+error_free_trigger:
+       iio_trigger_free(trig);
 error_ret:
        return ret;
 }
@@ -99,7 +99,7 @@ static int iio_interrupt_trigger_remove(struct platform_device *pdev)
        iio_trigger_unregister(trig);
        free_irq(trig_info->irq, trig);
        kfree(trig_info);
-       iio_trigger_put(trig);
+       iio_trigger_free(trig);
 
        return 0;
 }
index 3dfab2bc6d6935368a6cec8cd5b45617a921bb0a..202e8b89caf2deda6c63bba11a30f32c91ed908c 100644 (file)
@@ -174,7 +174,7 @@ static int iio_sysfs_trigger_probe(int id)
        return 0;
 
 out2:
-       iio_trigger_put(t->trig);
+       iio_trigger_free(t->trig);
 free_t:
        kfree(t);
 out1:
index 9658f2097c957a7df333d568f8f69f6136dee9d2..4e0b4eedb53d52c96ae9f8765235ed5fb033a4d8 100644 (file)
@@ -260,7 +260,7 @@ out_free_irq:
 out1:
        iio_trigger_unregister(st->trig);
 out:
-       iio_trigger_put(st->trig);
+       iio_trigger_free(st->trig);
        return ret;
 }
 
@@ -273,7 +273,7 @@ static int iio_bfin_tmr_trigger_remove(struct platform_device *pdev)
                peripheral_free(st->t->pin);
        free_irq(st->irq, st);
        iio_trigger_unregister(st->trig);
-       iio_trigger_put(st->trig);
+       iio_trigger_free(st->trig);
 
        return 0;
 }