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

Commit 57a21c1b authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman
Browse files

USB: don't try to kzalloc 0 bytes



This patch (as907) prevents us from trying to allocate 0 bytes
when an interface has no endpoint descriptors.

Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent b89ee19a
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -185,10 +185,12 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
		num_ep = USB_MAXENDPOINTS;
	}

	if (num_ep > 0) {	/* Can't allocate 0 bytes */
		len = sizeof(struct usb_host_endpoint) * num_ep;
		alt->endpoint = kzalloc(len, GFP_KERNEL);
		if (!alt->endpoint)
			return -ENOMEM;
	}

	/* Parse all the endpoint descriptors */
	n = 0;