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

Commit 3de27838 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "USB: diag: Add check for ctxt in usb_diag_request_size()"

parents 707bc030 3402a90f
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -462,6 +462,7 @@ int usb_diag_alloc_req(struct usb_diag_ch *ch, int n_write, int n_read)
}
EXPORT_SYMBOL(usb_diag_alloc_req);
#define DWC3_MAX_REQUEST_SIZE (16 * 1024 * 1024)
#define CI_MAX_REQUEST_SIZE   (16 * 1024)
/**
 * usb_diag_request_size - Max request size for controller
 * @ch: Channel handler
@@ -471,6 +472,16 @@ EXPORT_SYMBOL(usb_diag_alloc_req);
 */
int usb_diag_request_size(struct usb_diag_ch *ch)
{
	struct diag_context *ctxt = ch->priv_usb;
	struct usb_composite_dev *cdev;

	if (!ctxt)
		return 0;

	cdev = ctxt->cdev;
	if (cdev->gadget->is_chipidea)
		return CI_MAX_REQUEST_SIZE;

	return DWC3_MAX_REQUEST_SIZE;
}
EXPORT_SYMBOL(usb_diag_request_size);