Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions drivers/usb/core/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
struct usb_interface_cache *intfc;
struct usb_host_interface *alt;
int i, n;
int len, retval;
int retval;
int num_ep, num_ep_orig;

d = (struct usb_interface_descriptor *) buffer;
Expand Down Expand Up @@ -371,8 +371,7 @@ static int usb_parse_interface(struct device *ddev, int cfgno,

if (num_ep > 0) {
/* Can't allocate 0 bytes */
len = sizeof(struct usb_host_endpoint) * num_ep;
alt->endpoint = kzalloc(len, GFP_KERNEL);
alt->endpoint = kcalloc(num_ep, sizeof(struct usb_host_endpoint), GFP_KERNEL);
if (!alt->endpoint)
return -ENOMEM;
}
Expand Down Expand Up @@ -418,7 +417,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
unsigned char *buffer2;
int size2;
struct usb_descriptor_header *header;
int len, retval;
int cache_size, retval;
u8 inums[USB_MAXINTERFACES], nalts[USB_MAXINTERFACES];
unsigned iad_num = 0;

Expand Down Expand Up @@ -563,8 +562,8 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
nalts[i] = j = USB_MAXALTSETTING;
}

len = sizeof(*intfc) + sizeof(struct usb_host_interface) * j;
config->intf_cache[i] = intfc = kzalloc(len, GFP_KERNEL);
cache_size = sizeof(*intfc) + sizeof(struct usb_host_interface);
config->intf_cache[i] = intfc = kcalloc(j, cache_size, GFP_KERNEL);
if (!intfc)
return -ENOMEM;
kref_init(&intfc->ref);
Expand Down Expand Up @@ -674,13 +673,11 @@ int usb_get_configuration(struct usb_device *dev)
return -EINVAL;
}

length = ncfg * sizeof(struct usb_host_config);
dev->config = kzalloc(length, GFP_KERNEL);
dev->config = kcalloc(ncfg, sizeof(struct usb_host_config), GFP_KERNEL);
if (!dev->config)
goto err2;

length = ncfg * sizeof(char *);
dev->rawdescriptors = kzalloc(length, GFP_KERNEL);
dev->rawdescriptors = kcalloc(ncfg, sizeof(char *), GFP_KERNEL);
if (!dev->rawdescriptors)
goto err2;

Expand Down