提交 cbb22ebc 编写于 作者: M Michael Thalmeier 提交者: Peter Chen

usb: chipidea: core: check before accessing ci_role in ci_role_show

ci_role BUGs when the role is >= CI_ROLE_END.
This is the case while the role is changing.
Signed-off-by: NMichael Thalmeier <michael.thalmeier@hale.at>
Signed-off-by: NPeter Chen <peter.chen@nxp.com>
上级 0340ff83
...@@ -843,7 +843,10 @@ static ssize_t ci_role_show(struct device *dev, struct device_attribute *attr, ...@@ -843,7 +843,10 @@ static ssize_t ci_role_show(struct device *dev, struct device_attribute *attr,
{ {
struct ci_hdrc *ci = dev_get_drvdata(dev); struct ci_hdrc *ci = dev_get_drvdata(dev);
return sprintf(buf, "%s\n", ci_role(ci)->name); if (ci->role != CI_ROLE_END)
return sprintf(buf, "%s\n", ci_role(ci)->name);
return 0;
} }
static ssize_t ci_role_store(struct device *dev, static ssize_t ci_role_store(struct device *dev,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册