[PATCH 5/8] Input: adi - simplify device name formatting

From: Dmitry Torokhov

Date: Mon Nov 30 2026 - 00:43:12 EST


Currently adi_init_input() formats the device name in two steps through
a temporary stack buffer, passing the model name string as a non-literal
format argument and mistakenly bounding that buffer with the physical
path length constant instead of the buffer's own size.

Set the unknown-model entry's name to NULL and format directly into the
device name buffer using literal format strings based on whether a
model name is present, removing the intermediate stack buffer while
preserving the resulting device names.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/input/joystick/adi.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
index a016a73cca27..34febfc54ae3 100644
--- a/drivers/input/joystick/adi.c
+++ b/drivers/input/joystick/adi.c
@@ -96,7 +96,7 @@ static const struct adi_model adi_models[] = {
[ADI_ID_WMED3D] = ADI_MODEL("WingMan Extreme Digital 3D", adi_wmed3d_abs, adi_wmed3d_key),
[ADI_ID_WGPE] = ADI_MODEL("WingMan GamePad Extreme", adi_wmgpe_abs, adi_wmgpe_key),
[ADI_ID_WGP_USB] = ADI_MODEL("WingMan GamePad USB", adi_wmgpe_abs, adi_wmgpe_key),
- [ADI_ID_MAX] = ADI_MODEL("Unknown Device %#x", adi_wmi_abs, adi_wmi_key),
+ [ADI_ID_MAX] = ADI_MODEL(NULL, adi_wmi_abs, adi_wmi_key),
};

/*
@@ -454,15 +454,19 @@ static void adi_id_decode(struct adi *adi, struct adi_port *port)
static int adi_init_input(struct adi *adi, struct adi_port *port, int half)
{
struct input_dev *input_dev;
- char buf[ADI_MAX_NAME_LENGTH];
int i;

adi->dev = input_dev = input_allocate_device();
if (!input_dev)
return -ENOMEM;

- snprintf(buf, ADI_MAX_PHYS_LENGTH, adi->model->name, adi->id);
- scnprintf(adi->name, ADI_MAX_NAME_LENGTH, "Logitech %s [%s]", buf, adi->cname);
+ if (adi->model->name)
+ scnprintf(adi->name, sizeof(adi->name),
+ "Logitech %s [%s]", adi->model->name, adi->cname);
+ else
+ scnprintf(adi->name, sizeof(adi->name),
+ "Logitech Unknown Device %#x [%s]",
+ adi->id, adi->cname);
snprintf(adi->phys, ADI_MAX_PHYS_LENGTH, "%s/input%d", port->gameport->phys, half);

input_dev->name = adi->name;
--
2.56.1.839.g22a8290db9-goog