From: Kisang Lee Date: Mon, 25 Jun 2018 05:36:04 +0000 (+0900) Subject: [COMMON] usb: typec: check invalid accessory id X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6ff144ae87a71fad6e2b80ffa35a3fb7754ef1ee;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] usb: typec: check invalid accessory id Change-Id: I243f47c1782cf59f0be9b2caf754d5bf4ba05a19 Signed-off-by: Kisang Lee --- diff --git a/drivers/usb/typec/typec.c b/drivers/usb/typec/typec.c index 24e355ba109d..393c79e191d9 100644 --- a/drivers/usb/typec/typec.c +++ b/drivers/usb/typec/typec.c @@ -432,7 +432,14 @@ static ssize_t accessory_mode_show(struct device *dev, 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]); }