diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2026-02-20 18:57:58 -0800 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2026-02-28 18:20:48 -0800 |
| commit | 1fe01b817921d2bbb10cc9c83d36364738ecfe5d (patch) | |
| tree | 8897919cb86b14e4ba99a2924224e296afa90c2f | |
| parent | 0c695e6b90674c67e03866123456cabfe1f74d9c (diff) | |
Input: atkbd - use __free() cleanup facility in when parsing FW keymap
Annotating the temporary keymap pointer as __free(kfree) ensures that it
will get released when exiting the function and explicit freeing in all
the return paths can be removed.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
| -rw-r--r-- | drivers/input/keyboard/atkbd.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 7e6fa0e3cbd8..4459de0e6615 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -1088,7 +1088,6 @@ static int atkbd_get_keymap_from_fwnode(struct atkbd *atkbd) { struct device *dev = &atkbd->ps2dev.serio->dev; int i, n; - u32 *ptr; u16 scancode, keycode; /* Parse "linux,keymap" property */ @@ -1096,13 +1095,12 @@ static int atkbd_get_keymap_from_fwnode(struct atkbd *atkbd) if (n <= 0 || n > ATKBD_KEYMAP_SIZE) return -ENXIO; - ptr = kcalloc(n, sizeof(u32), GFP_KERNEL); + u32 *ptr __free(kfree) = kcalloc(n, sizeof(*ptr), GFP_KERNEL); if (!ptr) return -ENOMEM; if (device_property_read_u32_array(dev, "linux,keymap", ptr, n)) { dev_err(dev, "problem parsing FW keymap property\n"); - kfree(ptr); return -EINVAL; } @@ -1113,13 +1111,11 @@ static int atkbd_get_keymap_from_fwnode(struct atkbd *atkbd) if (scancode >= ATKBD_KEYMAP_SIZE) { dev_warn(dev, "invalid scancode %#x in FW keymap entry %d\n", scancode, i); - kfree(ptr); return -EINVAL; } atkbd->keycode[scancode] = keycode; } - kfree(ptr); return 0; } |
