Re: [PATCH 3/3] Input: atmel_mxt_ts - use __free() for obuf in mxt_object_show

From: Ricardo Ribalda

Date: Tue May 05 2026 - 05:22:11 EST


On Mon, 4 May 2026 at 20:54, Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx> wrote:
>
> Use the __free(kfree) macro for the obuf allocation in mxt_object_show()
> to simplify the code.
>
> Assisted-by: Gemini:gemini-3.1-pro
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
Reviewed-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>
> ---
> drivers/input/touchscreen/atmel_mxt_ts.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
> index d660cc5b5fe3..6af4db5ed117 100644
> --- a/drivers/input/touchscreen/atmel_mxt_ts.c
> +++ b/drivers/input/touchscreen/atmel_mxt_ts.c
> @@ -2870,14 +2870,12 @@ static ssize_t mxt_object_show(struct device *dev,
> int count = 0;
> int i, j;
> int error;
> - u8 *obuf;
>
> /* Pre-allocate buffer large enough to hold max sized object. */
> - obuf = kmalloc(256, GFP_KERNEL);
> + u8 *obuf __free(kfree) = kmalloc(256, GFP_KERNEL);
> if (!obuf)
> return -ENOMEM;
>
> - error = 0;
> for (i = 0; i < data->info->object_num; i++) {
> object = data->object_table + i;
>
> @@ -2892,15 +2890,13 @@ static ssize_t mxt_object_show(struct device *dev,
>
> error = __mxt_read_reg(data->client, addr, size, obuf);
> if (error)
> - goto done;
> + return error;
>
> count = mxt_show_instance(buf, count, object, j, obuf);
> }
> }
>
> -done:
> - kfree(obuf);
> - return error ?: count;
> + return count;
> }
>
> static int mxt_check_firmware_format(struct device *dev,
> --
> 2.54.0.545.g6539524ca2-goog
>


--
Ricardo Ribalda