diff options
| author | Arumuga Durai A <cadurai@codeaurora.org> | 2016-05-05 12:53:29 +0530 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-07-15 02:36:33 -0700 |
| commit | 9ac17853930c9db6feafc80d50ac200eb67a71cc (patch) | |
| tree | 248ebda158bd59081db185051af40ea94c4e2a32 /drivers/usb/gadget/function | |
| parent | aa958278d16faccd0cc79650b94ea6aa18d4131d (diff) | |
USB: gadget: serial: Fix debugfs crash
Serial function driver creates debugfs files even though ports
are not allocated. Fetching/reading those files without allocation
of ports leads to crash. Check port allocation before creating
the files.
Change-Id: I85b050a261cca6f961d5d9058efb8b7facf242ce
Signed-off-by: Arumuga Durai A <cadurai@codeaurora.org>
Diffstat (limited to 'drivers/usb/gadget/function')
| -rw-r--r-- | drivers/usb/gadget/function/u_serial.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c index bea936a6678b..e0b77946f013 100644 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -1258,6 +1258,9 @@ static ssize_t debug_read_status(struct file *file, char __user *ubuf, int ret; int result = 0; + if (!ui_dev) + return -EINVAL; + tty = ui_dev->port.tty; gser = ui_dev->port_usb; @@ -1307,6 +1310,9 @@ static ssize_t debug_write_reset(struct file *file, const char __user *buf, struct gs_port *ui_dev = file->private_data; unsigned long flags; + if (!ui_dev) + return -EINVAL; + spin_lock_irqsave(&ui_dev->port_lock, flags); ui_dev->nbytes_from_host = ui_dev->nbytes_to_tty = ui_dev->nbytes_from_tty = ui_dev->nbytes_to_host = 0; @@ -1336,6 +1342,9 @@ static void usb_debugfs_init(struct gs_port *ui_dev, int port_num) { char buf[48]; + if (!ui_dev) + return; + snprintf(buf, 48, "usb_serial%d", port_num); gs_dent = debugfs_create_dir(buf, 0); if (!gs_dent || IS_ERR(gs_dent)) |
