usb: chipidea: debug: check before accessing ci_role
authorMichael Thalmeier <michael.thalmeier@hale.at>
Thu, 18 May 2017 14:14:14 +0000 (16:14 +0200)
committerPeter Chen <peter.chen@nxp.com>
Tue, 23 May 2017 00:36:46 +0000 (08:36 +0800)
ci_role BUGs when the role is >= CI_ROLE_END.

Cc: stable@vger.kernel.org #v3.10+
Signed-off-by: Michael Thalmeier <michael.thalmeier@hale.at>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
drivers/usb/chipidea/debug.c

index 6d23eede4d8cda5014b041f965f3e060d201be74..1c31e8a088101ff70d3aa37553d1e9b2d906b324 100644 (file)
@@ -294,7 +294,8 @@ static int ci_role_show(struct seq_file *s, void *data)
 {
        struct ci_hdrc *ci = s->private;
 
-       seq_printf(s, "%s\n", ci_role(ci)->name);
+       if (ci->role != CI_ROLE_END)
+               seq_printf(s, "%s\n", ci_role(ci)->name);
 
        return 0;
 }