Skip to content

Commit

Permalink
phy: qcom-qmp: Zero-initialize typec switch descriptor
Browse files Browse the repository at this point in the history
When registering a typec switch, typec_switch_register() expects the
name field of the provided struct typec_switch_desc to be either set to
a valid string or initialized with NULL. If it instead has been
initialized by some random bytes from the stack, we may end up with a
switch name of '(efault)-switch'. Furthermore, if we add multiple
switches, registration may fail due to duplicate sysfs names.

Zero-initialize the switch descriptor to fix this.

Fixes: a6970d2 ("phy: qcom-qmp: Register as a typec switch for orientation detection")
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  • Loading branch information
qzed committed Jun 9, 2022
1 parent 4029dab commit 6ccacac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/phy/qualcomm/phy-qcom-qmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -6218,7 +6218,7 @@ static int qcom_qmp_phy_typec_switch_set(struct typec_switch_dev *sw,

static int qcom_qmp_phy_typec_switch_register(struct qcom_qmp *qmp, const struct qmp_phy_cfg *cfg)
{
struct typec_switch_desc sw_desc;
struct typec_switch_desc sw_desc = {};
struct device *dev = qmp->dev;

if (cfg->has_phy_dp_com_ctrl) {
Expand Down

0 comments on commit 6ccacac

Please sign in to comment.