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>
int ret;
int result = 0;
+ if (!ui_dev)
+ return -EINVAL;
+
tty = ui_dev->port.tty;
gser = ui_dev->port_usb;
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;
{
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))