From: "Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: Alison Schofield <amsfield22@gmail.com>,
Jonathan Cameron <jic23@kernel.org>,
"Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com>
Subject: [PATCH AUTOSEL for 3.18 06/15] iio: trigger: free trigger resource correctly
Date: Wed, 25 Oct 2017 01:56:28 +0000 [thread overview]
Message-ID: <20171025015622.24698-6-alexander.levin@verizon.com> (raw)
In-Reply-To: <20171025015622.24698-1-alexander.levin@verizon.com>
From: Alison Schofield <amsfield22@gmail.com>
[ 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>
---
drivers/iio/trigger/iio-trig-interrupt.c | 8 ++++----
drivers/iio/trigger/iio-trig-sysfs.c | 2 +-
drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/trigger/iio-trig-interrupt.c b/drivers/iio/trigger/iio-trig-interrupt.c
index 572bc6f02ca8..e18f12b74610 100644
--- a/drivers/iio/trigger/iio-trig-interrupt.c
+++ b/drivers/iio/trigger/iio-trig-interrupt.c
@@ -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;
}
diff --git a/drivers/iio/trigger/iio-trig-sysfs.c b/drivers/iio/trigger/iio-trig-sysfs.c
index 254c7e906127..61ffbec048a7 100644
--- a/drivers/iio/trigger/iio-trig-sysfs.c
+++ b/drivers/iio/trigger/iio-trig-sysfs.c
@@ -173,7 +173,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:
diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
index a21b7c514776..b412f567a9c1 100644
--- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
+++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
@@ -258,7 +258,7 @@ out_free_irq:
out1:
iio_trigger_unregister(st->trig);
out:
- iio_trigger_put(st->trig);
+ iio_trigger_free(st->trig);
return ret;
}
@@ -271,7 +271,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;
}
--
2.11.0
next prev parent reply other threads:[~2017-10-25 2:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-25 1:56 [PATCH AUTOSEL for 3.18 01/15] video: fbdev: pmag-ba-fb: Remove bad `__init' annotation Levin, Alexander (Sasha Levin)
2017-10-25 1:56 ` [PATCH AUTOSEL for 3.18 02/15] xen/netback: set default upper limit of tx/rx queues to 8 Levin, Alexander (Sasha Levin)
2017-10-25 1:56 ` [PATCH AUTOSEL for 3.18 03/15] ARM: dts: imx53-qsb-common: fix FEC pinmux config Levin, Alexander (Sasha Levin)
2017-10-25 1:56 ` [PATCH AUTOSEL for 3.18 04/15] drm: drm_minor_register(): Clean up debugfs on failure Levin, Alexander (Sasha Levin)
2017-10-25 1:56 ` [PATCH AUTOSEL for 3.18 05/15] ARM: omap2plus_defconfig: Fix probe errors on UARTs 5 and 6 Levin, Alexander (Sasha Levin)
2017-10-25 1:56 ` Levin, Alexander (Sasha Levin) [this message]
2017-10-25 1:56 ` [PATCH AUTOSEL for 3.18 08/15] dt-bindings: Add vendor prefix for LEGO Levin, Alexander (Sasha Levin)
2017-10-25 1:56 ` [PATCH AUTOSEL for 3.18 09/15] phy: increase size of MII_BUS_ID_SIZE and bus_id Levin, Alexander (Sasha Levin)
2017-10-25 1:56 ` [PATCH AUTOSEL for 3.18 10/15] serial: sh-sci: Fix register offsets for the IRDA serial port Levin, Alexander (Sasha Levin)
2017-10-25 1:56 ` [PATCH AUTOSEL for 3.18 07/15] dt-bindings: Add LEGO MINDSTORMS EV3 compatible specification Levin, Alexander (Sasha Levin)
2017-10-25 1:56 ` [PATCH AUTOSEL for 3.18 13/15] Input: mpr121 - handle multiple bits change of status register Levin, Alexander (Sasha Levin)
2017-10-25 1:56 ` [PATCH AUTOSEL for 3.18 11/15] usb: hcd: initialize hcd->flags to 0 when rm hcd Levin, Alexander (Sasha Levin)
2017-10-25 1:56 ` [PATCH AUTOSEL for 3.18 14/15] Input: mpr121 - set missing event capability Levin, Alexander (Sasha Levin)
2017-10-25 1:56 ` [PATCH AUTOSEL for 3.18 12/15] IPsec: do not ignore crypto err in ah4 input Levin, Alexander (Sasha Levin)
2017-10-25 1:56 ` [PATCH AUTOSEL for 3.18 15/15] IB/ipoib: Change list_del to list_del_init in the tx object Levin, Alexander (Sasha Levin)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171025015622.24698-6-alexander.levin@verizon.com \
--to=alexander.levin@verizon.com \
--cc=amsfield22@gmail.com \
--cc=jic23@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®