Change-Id: I243f47c1782cf59f0be9b2caf754d5bf4ba05a19
Signed-off-by: Kisang Lee <kisang80.lee@samsung.com>
struct device_attribute *attr,
char *buf)
{
- struct typec_partner *p = to_typec_partner(dev);
+ struct typec_partner *p;
+
+ p = to_typec_partner(dev);
+
+ if (p->accessory > TYPEC_MAX_ACCESSORY) {
+ pr_err("%s Invalid accessory number...", __func__);
+ return sprintf(buf, "%s\n", typec_accessory_modes[0]);
+ }
return sprintf(buf, "%s\n", typec_accessory_modes[p->accessory]);
}