Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3881e137 authored by Hemant Kumar's avatar Hemant Kumar
Browse files

usb: gadget: f_gsi: Check USB connection status in ioctl



In case of mdm subsystem re-start when usb is in disconnect
state, qti issues QTI_CTRL_MODEM_OFFLINE ioctl. This is
resulting into config NULL pointer dereference to access
usb composite device struct. Fix this issue by adding a
check for cable connection status before handling any ioctl.
Also move access of cdev pointer after usb connection status
check in gsi_ctrl_send_notification().

Change-Id: I8e62b69cfa4da0300d02d4bf6ddaf445f4577ba5
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent 597b0885
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -1439,9 +1439,9 @@ static long gsi_ctrl_dev_ioctl(struct file *fp, unsigned int cmd,
	gsi = inst_cur->opts->gsi;
	c_port = &gsi->c_port;

	if (!c_port) {
		log_event_err("%s: gsi ctrl port %pK", __func__, c_port);
		return -ENODEV;
	if (!atomic_read(&gsi->connected)) {
		log_event_err("USB cable not connected\n");
		return -ECONNRESET;
	}

	switch (cmd) {
@@ -1801,7 +1801,7 @@ static int gsi_ctrl_send_notification(struct f_gsi *gsi)
	__le32 *data;
	struct usb_cdc_notification *event;
	struct usb_request *req = gsi->c_port.notify_req;
	struct usb_composite_dev *cdev = gsi->function.config->cdev;
	struct usb_composite_dev *cdev;
	struct gsi_ctrl_pkt *cpkt;
	unsigned long flags;
	bool del_free_cpkt = false;
@@ -1832,6 +1832,7 @@ static int gsi_ctrl_send_notification(struct f_gsi *gsi)
	log_event_dbg("%s: cpkt->type:%d\n", __func__, cpkt->type);

	event = req->buf;
	cdev = gsi->function.config->cdev;

	switch (cpkt->type) {
	case GSI_CTRL_NOTIFY_CONNECT: