Skip to content

Commit 65c95f7

Browse files
Jiri Pirkokuba-moo
authored andcommitted
dpll: sanitize possible null pointer dereference in dpll_pin_parent_pin_set()
User may not pass DPLL_A_PIN_STATE attribute in the pin set operation message. Sanitize that by checking if the attr pointer is not null and process the passed state attribute value only in that case. Reported-by: Xingyuan Mo <[email protected]> Fixes: 9d71b54 ("dpll: netlink: Add DPLL framework base functions") Signed-off-by: Jiri Pirko <[email protected]> Acked-by: Vadim Fedorenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 154bb2f commit 65c95f7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drivers/dpll/dpll_netlink.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,6 @@ dpll_pin_parent_pin_set(struct dpll_pin *pin, struct nlattr *parent_nest,
925925
struct netlink_ext_ack *extack)
926926
{
927927
struct nlattr *tb[DPLL_A_PIN_MAX + 1];
928-
enum dpll_pin_state state;
929928
u32 ppin_idx;
930929
int ret;
931930

@@ -936,10 +935,14 @@ dpll_pin_parent_pin_set(struct dpll_pin *pin, struct nlattr *parent_nest,
936935
return -EINVAL;
937936
}
938937
ppin_idx = nla_get_u32(tb[DPLL_A_PIN_PARENT_ID]);
939-
state = nla_get_u32(tb[DPLL_A_PIN_STATE]);
940-
ret = dpll_pin_on_pin_state_set(pin, ppin_idx, state, extack);
941-
if (ret)
942-
return ret;
938+
939+
if (tb[DPLL_A_PIN_STATE]) {
940+
enum dpll_pin_state state = nla_get_u32(tb[DPLL_A_PIN_STATE]);
941+
942+
ret = dpll_pin_on_pin_state_set(pin, ppin_idx, state, extack);
943+
if (ret)
944+
return ret;
945+
}
943946

944947
return 0;
945948
}

0 commit comments

Comments
 (0)