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

Commit cb0304a9 authored by Hemant Kumar's avatar Hemant Kumar Committed by Mayank Rana
Browse files

usb: gadget: Do not disconnect unregistered dev



configfs_composite_unbind sets the gadget data
to null. Therefore, add check in android_disconnect
function to make sure that cdev is not NULL. This
prevents NULL pointer dereference upon accessing
cdev.

CRs-Fixed: 10841367
Change-Id: Ib59cdd88557d917c85d8d33968efc295bcef2280
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent 08abc848
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -1521,7 +1521,14 @@ static int android_setup(struct usb_gadget *gadget,
static void android_disconnect(struct usb_gadget *gadget)
{
	struct usb_composite_dev        *cdev = get_gadget_data(gadget);
	struct gadget_info *gi = container_of(cdev, struct gadget_info, cdev);
	struct gadget_info *gi;

	if (!cdev) {
		pr_err("%s: gadget is not connected\n", __func__);
		return;
	}

	gi = container_of(cdev, struct gadget_info, cdev);

	/* accessory HID support can be active while the
		accessory function is not actually enabled,