ALSA: usb-audio: Use kmemdup rather than duplicating its implementation
Use kmemdup rather than duplicating its implementation The semantic patch that makes this change is available in scripts/coccinelle/api/memdup.cocci. Signed-off-by: Thomas Meyer <thomas@m3y3r.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
2f451d2a2a
commit
43df2a57b7
1 changed files with 3 additions and 4 deletions
|
@ -137,12 +137,12 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
if (fp->nr_rates > 0) {
|
if (fp->nr_rates > 0) {
|
||||||
rate_table = kmalloc(sizeof(int) * fp->nr_rates, GFP_KERNEL);
|
rate_table = kmemdup(fp->rate_table,
|
||||||
|
sizeof(int) * fp->nr_rates, GFP_KERNEL);
|
||||||
if (!rate_table) {
|
if (!rate_table) {
|
||||||
kfree(fp);
|
kfree(fp);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
memcpy(rate_table, fp->rate_table, sizeof(int) * fp->nr_rates);
|
|
||||||
fp->rate_table = rate_table;
|
fp->rate_table = rate_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,10 +224,9 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip,
|
||||||
if (altsd->bNumEndpoints != 1)
|
if (altsd->bNumEndpoints != 1)
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
||||||
fp = kmalloc(sizeof(*fp), GFP_KERNEL);
|
fp = kmemdup(&ua_format, sizeof(*fp), GFP_KERNEL);
|
||||||
if (!fp)
|
if (!fp)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
memcpy(fp, &ua_format, sizeof(*fp));
|
|
||||||
|
|
||||||
fp->iface = altsd->bInterfaceNumber;
|
fp->iface = altsd->bInterfaceNumber;
|
||||||
fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
|
fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
|
||||||
|
|
Loading…
Reference in a new issue