Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc477961 authored by Vivek Aknurwar's avatar Vivek Aknurwar
Browse files

clk: qcom: clk-debug: Fix possible NULL dereference in _mux_get_parent



Fix possible NULL dereference in retrieving clk parent name.

Change-Id: Ic4dbc6632f00365ea127042c0f3bd9b66a243ec6
Signed-off-by: default avatarVivek Aknurwar <viveka@codeaurora.org>
parent 2c30b064
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -146,13 +146,17 @@ static u8 clk_debug_mux_get_parent(struct clk_hw *hw)
{
	int i, num_parents = clk_hw_get_num_parents(hw);
	struct clk_hw *hw_clk = clk_hw_get_parent(hw);
	struct clk_hw *clk_parent;
	const char *parent;

	if (!hw_clk)
		return 0;

	for (i = 0; i < num_parents; i++) {
		parent = clk_hw_get_name(clk_hw_get_parent_by_index(hw, i));
		clk_parent = clk_hw_get_parent_by_index(hw, i);
		if (!clk_parent)
			return 0;
		parent = clk_hw_get_name(clk_parent);
		if (!strcmp(parent, clk_hw_get_name(hw_clk))) {
			pr_debug("%s: clock parent - %s, index %d\n", __func__,
				parent, i);