[PM][PATCH 1/2] omap: opp: make opp_get_opp_id robust

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



opp_get_opp_id should handle the error cases that might hit it. check
parameters before using it

Signed-off-by: Nishanth Menon <nm@xxxxxx>

Cc: Eduardo Valentin <eduardo.valentin@xxxxxxxxx>
Cc: Jouni Hogander <jouni.hogander@xxxxxxxxx>
Cc: Kevin Hilman <khilman@xxxxxxxxxxxxxxxxxxx>
Cc: Paul Walmsley <paul@xxxxxxxxx>
Cc: Rajendra Nayak <rnayak@xxxxxx>
Cc: Sanjeev Premi <premi@xxxxxx>
Cc: Tero Kristo <tero.kristo@xxxxxxxxx>
Cc: Tony Lindgren <tony@xxxxxxxxxxx>
Cc: Vishwanath BS <vishwanath.bs@xxxxxx>
---
Note: even though this is a deprecated function, it should be robust

 arch/arm/plat-omap/opp.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/arm/plat-omap/opp.c b/arch/arm/plat-omap/opp.c
index 229960d..0b61325 100644
--- a/arch/arm/plat-omap/opp.c
+++ b/arch/arm/plat-omap/opp.c
@@ -101,6 +101,10 @@ struct omap_opp * __deprecated opp_find_by_opp_id(enum opp_t opp_type,
 
 u8 __deprecated opp_get_opp_id(struct omap_opp *opp)
 {
+	if (unlikely(!opp || IS_ERR(opp)) || !opp->enabled) {
+		pr_err("%s: Invalid parameter being passed\n", __func__);
+		return 0;
+	}
 	return opp->opp_id;
 }
 
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux