From: Suman Anna <s-anna-l0cyMroinI0@public.gmane.org>
To: Joerg Roedel <joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>,
Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
Laurent Pinchart
<laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>,
Florian Vaussard <florian.vaussard-p8DiymsW2f8@public.gmane.org>,
linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: [PATCHv3 02/13] iommu/omap: fix error return paths in omap_iommu_attach()
Date: Fri, 28 Feb 2014 14:42:33 -0600 [thread overview]
Message-ID: <1393620164-14633-3-git-send-email-s-anna@ti.com> (raw)
In-Reply-To: <1393620164-14633-1-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
There are couple of issues with the error return paths in
omap_iommu_attach():
1. omap_iommu_attach() returns NULL or ERR_PTR in case of error,
but omap_iommu_attach_dev() only checks for IS_ERR. Thus a NULL
return value (in case driver_find_device fails) will cause the
kernel to panic when omap_iommu_attach_dev() dereferences the
pointer.
2. A try_module_get() failure returns a valid success value as
returned from iommu_enable().
Both the above issues have been fixed up to return the proper
ERR_PTR.
Signed-off-by: Florian Vaussard <florian.vaussard-p8DiymsW2f8@public.gmane.org>
Signed-off-by: Suman Anna <s-anna-l0cyMroinI0@public.gmane.org>
---
drivers/iommu/omap-iommu.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index fff2ffd..647e4ba 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -863,7 +863,7 @@ static int device_match_by_alias(struct device *dev, void *data)
**/
static struct omap_iommu *omap_iommu_attach(const char *name, u32 *iopgd)
{
- int err = -ENOMEM;
+ int err;
struct device *dev;
struct omap_iommu *obj;
@@ -871,7 +871,7 @@ static struct omap_iommu *omap_iommu_attach(const char *name, u32 *iopgd)
(void *)name,
device_match_by_alias);
if (!dev)
- return NULL;
+ return ERR_PTR(-ENODEV);
obj = to_iommu(dev);
@@ -890,8 +890,10 @@ static struct omap_iommu *omap_iommu_attach(const char *name, u32 *iopgd)
goto err_enable;
flush_iotlb_all(obj);
- if (!try_module_get(obj->owner))
+ if (!try_module_get(obj->owner)) {
+ err = -ENODEV;
goto err_module;
+ }
spin_unlock(&obj->iommu_lock);
--
1.9.0
next prev parent reply other threads:[~2014-02-28 20:42 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-28 20:42 [PATCHv3 00/13] OMAP IOMMU DT adaptation for 3.15 Suman Anna
2014-02-28 20:42 ` [PATCHv3 05/13] iommu/omap: add devicetree support Suman Anna
[not found] ` <1393620164-14633-1-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
2014-02-28 20:42 ` [PATCHv3 01/13] iommu/omap: convert to devm_* interfaces Suman Anna
2014-02-28 20:42 ` Suman Anna [this message]
2014-02-28 20:42 ` [PATCHv3 03/13] iommu/omap: allow enable/disable even without pdata Suman Anna
2014-02-28 20:42 ` [PATCHv3 04/13] Documentation: dt: add OMAP iommu bindings Suman Anna
2014-02-28 20:42 ` [PATCHv3 06/13] iommu/omap: enable bus-error back on supported iommus Suman Anna
2014-02-28 20:42 ` [PATCHv3 07/13] iommu/omap: allocate archdata on the fly for DT-based devices Suman Anna
2014-02-28 20:42 ` [PATCHv3 08/13] ARM: OMAP3: remove deprecated CONFIG_OMAP_IOMMU_IVA2 Suman Anna
2014-02-28 20:42 ` [PATCHv3 10/13] ARM: OMAP2+: change the ISP device archdata MMU name for DT Suman Anna
2014-02-28 20:42 ` [PATCHv3 12/13] ARM: OMAP5: hwmod data: add mmu data for ipu & dsp Suman Anna
2014-02-28 20:42 ` [PATCHv3 13/13] ARM: OMAP2+: extend iommu pdata-quirks to OMAP5 Suman Anna
2014-02-28 23:00 ` [PATCHv3 00/13] OMAP IOMMU DT adaptation for 3.15 Tony Lindgren
2014-03-03 5:35 ` Suman Anna
[not found] ` <20140228230000.GW13624-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-03-04 16:04 ` Joerg Roedel
2014-03-04 16:52 ` Suman Anna
[not found] ` <20140304160432.GG2799-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2014-03-04 16:59 ` Suman Anna
[not found] ` <5316068F.3020003-l0cyMroinI0@public.gmane.org>
2014-03-05 19:33 ` Tony Lindgren
2014-03-05 20:07 ` Suman Anna
2014-02-28 20:42 ` [PATCHv3 09/13] ARM: OMAP3: fix iva mmu programming issues Suman Anna
2014-02-28 20:42 ` [PATCHv3 11/13] ARM: OMAP2+: use pdata quirks for iommu reset lines Suman Anna
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=1393620164-14633-3-git-send-email-s-anna@ti.com \
--to=s-anna-l0cymroini0@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=florian.vaussard-p8DiymsW2f8@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org \
--cc=laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.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;
as well as URLs for NNTP newsgroup(s).