mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
Input: rmi4 - use sizeof(*ptr) and idiomatic checks in f12 allocators
Using sizeof(*ptr) is preferred over sizeof(struct) because it is more robust against type changes. Also switch to checking for allocation failure immediately after each call, and update formatting. Assisted-by: Gemini:gemini-3.1-pro Link: https://patch.msgid.link/20260505045952.1570713-17-dmitry.torokhov@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
1ea51794d7
commit
57d9212421
|
|
@ -528,16 +528,21 @@ static int rmi_f12_probe(struct rmi_function *fn)
|
|||
}
|
||||
|
||||
/* allocate the in-kernel tracking buffers */
|
||||
sensor->tracking_pos = devm_kcalloc(&fn->dev,
|
||||
sensor->nbr_fingers, sizeof(struct input_mt_pos),
|
||||
GFP_KERNEL);
|
||||
sensor->tracking_slots = devm_kcalloc(&fn->dev,
|
||||
sensor->nbr_fingers, sizeof(int), GFP_KERNEL);
|
||||
sensor->objs = devm_kcalloc(&fn->dev,
|
||||
sensor->nbr_fingers,
|
||||
sizeof(struct rmi_2d_sensor_abs_object),
|
||||
GFP_KERNEL);
|
||||
if (!sensor->tracking_pos || !sensor->tracking_slots || !sensor->objs)
|
||||
sensor->tracking_pos = devm_kcalloc(&fn->dev, sensor->nbr_fingers,
|
||||
sizeof(*sensor->tracking_pos),
|
||||
GFP_KERNEL);
|
||||
if (!sensor->tracking_pos)
|
||||
return -ENOMEM;
|
||||
|
||||
sensor->tracking_slots = devm_kcalloc(&fn->dev, sensor->nbr_fingers,
|
||||
sizeof(*sensor->tracking_slots),
|
||||
GFP_KERNEL);
|
||||
if (!sensor->tracking_slots)
|
||||
return -ENOMEM;
|
||||
|
||||
sensor->objs = devm_kcalloc(&fn->dev, sensor->nbr_fingers,
|
||||
sizeof(*sensor->objs), GFP_KERNEL);
|
||||
if (!sensor->objs)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = rmi_2d_sensor_configure_input(fn, sensor);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user