We used to have a variable declaration with __free() initialized with
NULL. This was to keep the old coding style rule, but recently it's
relaxed and rather recommends to follow the new rule to declare in
place of use for __free() -- which avoids potential deadlocks or UAFs
with nested cleanups.
Although the current code has no bug, per se, let's follow the new
standard and move the declaration to the place of assignment (or
directly assign the allocated result) instead of NULL initializations.
Fixes: 67afec157fe6 ("ALSA: usb-audio: us144mkii: Add MIDI support and mixer controlsj")
Fixes: a2a2210f2c2e ("ALSA: usb-audio: us144mkii: Implement audio playback and feedback")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20251216140634.171890-11-tiwai@suse.de
struct snd_card *card;
struct tascam_card *tascam;
int err;
- char *handshake_buf __free(kfree) = NULL;
if (dev->speed != USB_SPEED_HIGH)
dev_info(
return -ENOENT;
}
- handshake_buf = kmalloc(1, GFP_KERNEL);
+ char *handshake_buf __free(kfree) =
+ kmalloc(1, GFP_KERNEL);
if (!handshake_buf)
return -ENOMEM;
{
struct tascam_card *tascam =
(struct tascam_card *)snd_kcontrol_chip(kcontrol);
- u8 *buf __free(kfree) = NULL;
int err;
u32 rate = 0;
}
}
- buf = kmalloc(3, GFP_KERNEL);
+ u8 *buf __free(kfree) =
+ kmalloc(3, GFP_KERNEL);
if (!buf)
return -ENOMEM;
int us144mkii_configure_device_for_rate(struct tascam_card *tascam, int rate)
{
struct usb_device *dev = tascam->dev;
- u8 *rate_payload_buf __free(kfree) = NULL;
u16 rate_vendor_wValue;
int err = 0;
const u8 *current_payload_src;
return -EINVAL;
}
- rate_payload_buf = kmemdup(current_payload_src, 3, GFP_KERNEL);
+ u8 *rate_payload_buf __free(kfree) =
+ kmemdup(current_payload_src, 3, GFP_KERNEL);
if (!rate_payload_buf)
return -ENOMEM;