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

Commit 564e6989 authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman
Browse files

USB: usbtest: prevent a divide by zero bug



If param->length is zero, then this could lead to a divide by zero bug
later in the function when we do: size %= max;

Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fb4e98ab
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -423,6 +423,9 @@ alloc_sglist(int nents, int max, int vary)
	unsigned		i;
	unsigned		size = max;

	if (max == 0)
		return NULL;

	sg = kmalloc_array(nents, sizeof *sg, GFP_KERNEL);
	if (!sg)
		return NULL;