From: Takashi Iwai <tiwai@suse.de>
To: linux-sound@vger.kernel.org
Subject: [PATCH 01/14] ALSA: 6fire: Use auto-cleanup for firmware loading
Date: Wed, 29 Jul 2026 10:37:19 +0200 [thread overview]
Message-ID: <20260729083735.120219-2-tiwai@suse.de> (raw)
In-Reply-To: <20260729083735.120219-1-tiwai@suse.de>
Clean up the code for managing the firmware loading in the 6fire
driver with __free(firmware) and __free(kfree), so that the loaded
firmware and the name string are cleaned up automatically.
Only the code refactoring, no functional changes.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/usb/6fire/firmware.c | 24 ++++--------------------
1 file changed, 4 insertions(+), 20 deletions(-)
diff --git a/sound/usb/6fire/firmware.c b/sound/usb/6fire/firmware.c
index 123c1c6539b8..d9dd8f44b047 100644
--- a/sound/usb/6fire/firmware.c
+++ b/sound/usb/6fire/firmware.c
@@ -194,23 +194,20 @@ static int usb6fire_fw_ezusb_upload(
int ret;
u8 data;
struct usb_device *device = interface_to_usbdev(intf);
- const struct firmware *fw = NULL;
- struct ihex_record *rec = kmalloc_obj(struct ihex_record);
+ struct ihex_record *rec __free(kfree) = kmalloc_obj(struct ihex_record);
if (!rec)
return -ENOMEM;
+ const struct firmware *fw __free(firmware) = NULL;
ret = request_firmware(&fw, fwname, &device->dev);
if (ret < 0) {
- kfree(rec);
dev_err(&intf->dev,
"error requesting ezusb firmware %s.\n", fwname);
return ret;
}
ret = usb6fire_fw_ihex_init(fw, rec);
if (ret < 0) {
- kfree(rec);
- release_firmware(fw);
dev_err(&intf->dev,
"error validating ezusb firmware %s.\n", fwname);
return ret;
@@ -219,8 +216,6 @@ static int usb6fire_fw_ezusb_upload(
data = 0x01; /* stop ezusb cpu */
ret = usb6fire_fw_ezusb_write(device, 0xa0, 0xe600, &data, 1);
if (ret) {
- kfree(rec);
- release_firmware(fw);
dev_err(&intf->dev,
"unable to upload ezusb firmware %s: begin message.\n",
fwname);
@@ -231,8 +226,6 @@ static int usb6fire_fw_ezusb_upload(
ret = usb6fire_fw_ezusb_write(device, 0xa0, rec->address,
rec->data, rec->len);
if (ret) {
- kfree(rec);
- release_firmware(fw);
dev_err(&intf->dev,
"unable to upload ezusb firmware %s: data urb.\n",
fwname);
@@ -240,8 +233,6 @@ static int usb6fire_fw_ezusb_upload(
}
}
- release_firmware(fw);
- kfree(rec);
if (postdata) { /* write data after firmware has been uploaded */
ret = usb6fire_fw_ezusb_write(device, 0xa0, postaddr,
postdata, postlen);
@@ -270,19 +261,18 @@ static int usb6fire_fw_fpga_upload(
int ret;
int i;
struct usb_device *device = interface_to_usbdev(intf);
- u8 *buffer = kmalloc(FPGA_BUFSIZE, GFP_KERNEL);
+ u8 *buffer __free(kfree) = kmalloc(FPGA_BUFSIZE, GFP_KERNEL);
const char *c;
const char *end;
- const struct firmware *fw;
if (!buffer)
return -ENOMEM;
+ const struct firmware *fw __free(firmware) = NULL;
ret = request_firmware(&fw, fwname, &device->dev);
if (ret < 0) {
dev_err(&intf->dev, "unable to get fpga firmware %s.\n",
fwname);
- kfree(buffer);
return -EIO;
}
@@ -291,8 +281,6 @@ static int usb6fire_fw_fpga_upload(
ret = usb6fire_fw_ezusb_write(device, 8, 0, NULL, 0);
if (ret) {
- kfree(buffer);
- release_firmware(fw);
dev_err(&intf->dev,
"unable to upload fpga firmware: begin urb.\n");
return ret;
@@ -304,15 +292,11 @@ static int usb6fire_fw_fpga_upload(
ret = usb6fire_fw_fpga_write(device, buffer, i);
if (ret < 0) {
- release_firmware(fw);
- kfree(buffer);
dev_err(&intf->dev,
"unable to upload fpga firmware: fw urb.\n");
return ret;
}
}
- release_firmware(fw);
- kfree(buffer);
ret = usb6fire_fw_ezusb_write(device, 9, 0, NULL, 0);
if (ret) {
--
2.55.0
next prev parent reply other threads:[~2026-07-29 8:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 8:37 [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading Takashi Iwai
2026-07-29 8:37 ` Takashi Iwai [this message]
2026-07-29 8:37 ` [PATCH 02/14] ALSA: hda: ca0132: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 03/14] ALSA: hda: intel: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 04/14] ALSA: msnd: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 05/14] ALSA: hda: cs35l41: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 06/14] ALSA: hda: cs35l56: " Takashi Iwai
2026-07-30 9:35 ` Charles Keepax
2026-07-30 9:45 ` Takashi Iwai
2026-07-30 10:21 ` Charles Keepax
2026-07-30 14:51 ` Richard Fitzgerald
2026-07-29 8:37 ` [PATCH 07/14] ALSA: sscape: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 08/14] ALSA: wavefront: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 09/14] ALSA: asihpi: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 10/14] ALSA: cs46xx: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 11/14] ALSA: korg1212: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 12/14] ALSA: mixart: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 13/14] ALSA: pcxhr: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 14/14] ALSA: sh: " Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260729083735.120219-2-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=linux-sound@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox