[PATCH master 1/2] clk: harden NULL handling in clk_hw_to_clk/clk_to_clk_hw

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

 



As clk_hw::clk is the first member and there may no be leading padding,
clk_hw_to_clk(NULL) == clk_to_clk_hw(NULL) == NULL. This would break if
we moved struct clk around, so make this more robust by using
IS_ERR_OR_NULL. No functional change.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 include/linux/clk.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/clk.h b/include/linux/clk.h
index c0e998e54ae6..7fd835c35e51 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -433,12 +433,14 @@ struct clk_hw {
 
 static inline struct clk *clk_hw_to_clk(const struct clk_hw *hw)
 {
-	return IS_ERR(hw) ? ERR_CAST(hw) : (struct clk *)&hw->clk;
+	return IS_ERR_OR_NULL(hw) ? ERR_CAST(hw)
+				  : (struct clk *)&hw->clk;
 }
 
 static inline struct clk_hw *clk_to_clk_hw(const struct clk *clk)
 {
-	return IS_ERR(clk) ? ERR_CAST(clk) : (struct clk_hw *)container_of(clk, struct clk_hw, clk);
+	return IS_ERR_OR_NULL(clk) ? ERR_CAST(clk)
+				   : (struct clk_hw *)container_of(clk, struct clk_hw, clk);
 }
 
 struct clk_div_table {
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux