HID: thrustmaster: Use scope-based resource management in thrustmaster_interrupts()
PATCH 1/1 HID: thrustmaster: Use scope-based resource management in thrustmaster_interrupts()
From: Markus Elfring <[email protected]>
Date: Mon, 28 Apr 2025 21:12:14 +0200
Scope-based resource management became supported for some programming interfaces by contributions of Peter Zijlstra on 2023-05-26. See also the commit 54da6a0924311c7cf5015533991e44fb8eb12773 ("locking:
Introduce __cleanup() based infrastructure").
* Thus use the attribute “__free(kfree)”.
* Omit four kfree() calls accordingly.
Signed-off-by Markus Elfring <[email protected]>
--- drivers/hid/hid-thrustmaster.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/hid/hid-thrustmaster.c +1 -6
@@ -150,7 +150,7 @@ static const struct usb_ctrlrequest change_request = {static void thrustmaster_interrupts (struct hid_device *hdev) {int ret, trans, i, b_ep; -u8 *send_buf =kmalloc (256 ,GFP_KERNEL ); + u8 *send_buf __free(kfree) = kmalloc(256, GFP_KERNEL);struct usb_host_endpoint *ep;struct device *dev = &hdev->dev;struct usb_interface *usbif =to_usb_interface (dev->parent);
@@ -162,7 +162,6 @@ static void thrustmaster_interrupts(struct hid_device *hdev) }if (usbif->cur_altsetting->desc.bNumEndpoints <2 ) { -kfree (send_buf);hid_err (hdev,"Wrong number of endpoints?\n" );return ; }
@@ -174,7 +173,6 @@ static void thrustmaster_interrupts(struct hid_device *hdev)u8 ep_addr[2 ] = {b_ep,0 };if (!usb_check_int_endpoints (usbif, ep_addr)) { -kfree (send_buf);hid_err (hdev,"Unexpected non-int endpoint\n" );return ; }
@@ -191,12 +189,9 @@ static void thrustmaster_interrupts(struct hid_device *hdev)if (ret) {hid_err (hdev,"setup data couldn't be sent\n" ); -kfree (send_buf);return ; } } - -kfree (send_buf); }static void thrustmaster_change_handler (struct urb *urb)
Signature · 1 line
2.49.0