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)
committerSasha Levin <alexander.levin@verizon.com>
Mon, 26 Jun 2017 02:02:19 +0000 (22:02 -0400)
[ Upstream commit 0340ff83cd4475261e7474033a381bc125b45244 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
drivers/usb/chipidea/debug.c

index 5b7061a331038d36ad20b7ec3c05b2ab1f8b3efc..bb8faf2845c7bdb01e56d66d76b541c0a110b661 100644 (file)
@@ -290,7 +290,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;
 }