All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thara Gopinath <thara@ti.com>
To: linux-omap@vger.kernel.org
Cc: Thara Gopinath <thara@ti.com>, Paul Walmsley <paul@pwsan.com>
Subject: [PATCH] OMAP3: hwmod: check for clkdomain pointer before accesing it to change the sleep dependencies.
Date: Sun,  6 Dec 2009 16:48:43 +0530	[thread overview]
Message-ID: <1260098323-26183-1-git-send-email-thara@ti.com> (raw)

Some clock nodes like wdt1_fck, sr1_fck, sr2_fck etc do not have a
clock domain associated . For such nodes accessing the clock domain pointers 
in _add_initiator_dep and _del_initiator_dep, will lead to null pointer
defreferencing crash. Adding support in these functions to check for
existence of clkdm pointer before trying to acess it. Even if tomorrow
we correct all the clock nodes to have an associated clock domain, checking
for the existence of the pointer is a good programming practice.

Signed-off-by: Thara Gopinath <thara@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
---
This patch depends on http://patchwork.kernel.org/patch/63383/

 arch/arm/mach-omap2/omap_hwmod.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 18e6478..3edc387 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -314,8 +314,10 @@ static int _add_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh)
 	if (!oh->_clk)
 		return -EINVAL;
 
-	return pwrdm_add_sleepdep(oh->_clk->clkdm->pwrdm.ptr,
+	if (oh->_clk->clkdm)
+		return pwrdm_add_sleepdep(oh->_clk->clkdm->pwrdm.ptr,
 				  init_oh->_clk->clkdm->pwrdm.ptr);
+	return 0;
 }
 
 /**
@@ -335,8 +337,10 @@ static int _del_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh)
 	if (!oh->_clk)
 		return -EINVAL;
 
-	return pwrdm_del_sleepdep(oh->_clk->clkdm->pwrdm.ptr,
+	if (oh->_clk->clkdm)
+		return pwrdm_del_sleepdep(oh->_clk->clkdm->pwrdm.ptr,
 				  init_oh->_clk->clkdm->pwrdm.ptr);
+	return 0;
 }
 
 /**
-- 
1.5.4.7


             reply	other threads:[~2009-12-06 11:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-06 11:18 Thara Gopinath [this message]
2009-12-09 23:08 ` [PATCH] OMAP3: hwmod: check for clkdomain pointer before accesing it to change the sleep dependencies Kevin Hilman
2009-12-10  6:34   ` Gopinath, Thara
2009-12-10 17:05     ` Kevin Hilman
2009-12-11  5:07       ` Gopinath, Thara
2009-12-11 16:12         ` Kevin Hilman
2009-12-14  7:05       ` Gopinath, Thara
2009-12-14 16:43         ` Kevin Hilman

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=1260098323-26183-1-git-send-email-thara@ti.com \
    --to=thara@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=paul@pwsan.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.