hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hid/hid-appleir.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * HID driver for the apple ir device
34 *
....@@ -12,15 +13,6 @@
1213 * Copyright (C) 2010, 2012 Bastien Nocera <hadess@hadess.net>
1314 * Copyright (C) 2013 Benjamin Tissoires <benjamin.tissoires@gmail.com>
1415 * Copyright (C) 2013 Red Hat Inc. All Rights Reserved
15
- *
16
- * This software is licensed under the terms of the GNU General Public
17
- * License version 2, as published by the Free Software Foundation, and
18
- * may be copied, distributed, and modified under those terms.
19
- *
20
- * This program is distributed in the hope that it will be useful,
21
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- * GNU General Public License for more details.
2416 */
2517
2618 #include <linux/device.h>
....@@ -291,11 +283,9 @@
291283 int ret;
292284 struct appleir *appleir;
293285
294
- appleir = kzalloc(sizeof(struct appleir), GFP_KERNEL);
295
- if (!appleir) {
296
- ret = -ENOMEM;
297
- goto allocfail;
298
- }
286
+ appleir = devm_kzalloc(&hid->dev, sizeof(struct appleir), GFP_KERNEL);
287
+ if (!appleir)
288
+ return -ENOMEM;
299289
300290 appleir->hid = hid;
301291
....@@ -321,8 +311,7 @@
321311
322312 return 0;
323313 fail:
324
- kfree(appleir);
325
-allocfail:
314
+ devm_kfree(&hid->dev, appleir);
326315 return ret;
327316 }
328317
....@@ -331,7 +320,6 @@
331320 struct appleir *appleir = hid_get_drvdata(hid);
332321 hid_hw_stop(hid);
333322 del_timer_sync(&appleir->key_up_timer);
334
- kfree(appleir);
335323 }
336324
337325 static const struct hid_device_id appleir_devices[] = {