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

Commit 3711c22b authored by Liangliang Lu's avatar Liangliang Lu
Browse files

usb: gadget: Fix NULL pointer access if NCM not instantiated



ncm_ctrlrequest() will be called in android_setup(), in the case
NCM instance is not created, structure _ncm_setup_desc is not
created, it will run into a NULL pointer exception.

Fix this by checking _ncm_setup_desc is NULL or not.

Change-Id: If8048a03a7ab46138739472327a17c65ce158382
Signed-off-by: default avatarLiangliang Lu <luliang@codeaurora.org>
parent f65c42f2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1634,7 +1634,8 @@ int ncm_ctrlrequest(struct usb_composite_dev *cdev,
{
	int value = -EOPNOTSUPP;

	if (ctrl->bRequestType == 0x40 && ctrl->bRequest == 0xF0) {
	if (ctrl->bRequestType == 0x40 && ctrl->bRequest == 0xF0
			&& _ncm_setup_desc) {
		_ncm_setup_desc->minor = (uint8_t)(ctrl->wValue >> 8);
		_ncm_setup_desc->major = (uint8_t)(ctrl->wValue & 0xFF);
		schedule_work(&_ncm_setup_desc->work);