Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD4E31B4223 for ; Tue, 3 Feb 2026 01:22:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.4 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770081756; cv=none; b=cQl4KQpNt2NHwk/QRL2X2QBXmVBfnooyxFYm7C4zv9I5ynkHHQL9iL5iuEadM4q8ZVcMiUu0FudRjPPkABK0bz+xj5zkhKtYWRyJzD5myzmn4GB/nw2vjYk+g+8zoQ8IgCvb8pzuSlSyZZqAfJGW2RlDvtXpzS6QsCY3jPWsPuM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770081756; c=relaxed/simple; bh=tOWgdQ+SSNrdHvQjeFI/zMdLkmetivEMKwQR04trjwo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=AvfED4Q323zv0zUwwMfJqz00A3Y/5me1iiLnXqSi4XRTBkx+vIoyq8Cy5dYBMwb5EW9FZvRAeYq+VK1fe85C027p+/O3nMtflKm/2R8iWvp9ifTyCttpQnCXv/XwVCWnPgG81m9DFpX26RM2mY816+2p5qKveL+B/SsH1jMKDoQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=at36EiaG; arc=none smtp.client-ip=117.135.210.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="at36EiaG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=FU Y//9efrwe/mUihSMNPvVmHkaeUq0H/+SPX8UvhvL0=; b=at36EiaGuUf+Tui+k1 3pJaV0Z9QCTtcNx3tE1K2AVeLJjxLuPJWkxBhyn62wiqKnv/VYErftgqJHKbXTe/ z8fPA46MZAJgxKLtjt2R7pxIUCo7jhZB02nweJkuU3FMS6rfl+UM9LMx++YzTxcO C0Wt4PvYY9x7IJNkcT6pqWAaE= Received: from ubuntu24.corp.ad.wrs.com (unknown []) by gzga-smtp-mtada-g1-2 (Coremail) with SMTP id _____wD3lwquTYFpoZcAJA--.30698S4; Tue, 03 Feb 2026 09:21:55 +0800 (CST) From: jetlan9@163.com To: stable@vger.kernel.org Cc: Rahul Rameshbabu , syzbot+3a0ebe8a52b89c63739d@syzkaller.appspotmail.com, Maxime Ripard , Dmitry Torokhov , Benjamin Tissoires , Wenshan Lan Subject: [PATCH 5.15.y 1/2] HID: uclogic: Correct devm device reference for hidinput input_dev name Date: Tue, 3 Feb 2026 01:21:43 +0000 Message-ID: <20260203012144.4215-1-jetlan9@163.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wD3lwquTYFpoZcAJA--.30698S4 X-Coremail-Antispam: 1Uf129KBjvJXoWxXw1xZF4fXry8Cw1rXw4Utwb_yoW5GFWxpF WfGanYkr4IgrnFkw4q9ay5Za4Yv397Gr15Way7Xw1rZw1avFyxKr9ayr9Fqr98JrWvkFs0 yF4SvF48Ka4UX37anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zNNtIwUUUUU= X-CM-SenderInfo: xmhwztjqz6il2tof0z/xtbCxBM6A2mBTbP7UwAA3Q From: Rahul Rameshbabu [ Upstream commit dd613a4e45f8d35f49a63a2064e5308fa5619e29 ] Reference the HID device rather than the input device for the devm allocation of the input_dev name. Referencing the input_dev would lead to a use-after-free when the input_dev was unregistered and subsequently fires a uevent that depends on the name. At the point of firing the uevent, the name would be freed by devres management. Use devm_kasprintf to simplify the logic for allocating memory and formatting the input_dev name string. Reported-by: syzbot+3a0ebe8a52b89c63739d@syzkaller.appspotmail.com Closes: https://lore.kernel.org/linux-input/ZOZIZCND+L0P1wJc@penguin/T/ Reported-by: Maxime Ripard Closes: https://lore.kernel.org/linux-input/ZOZIZCND+L0P1wJc@penguin/T/#m443f3dce92520f74b6cf6ffa8653f9c92643d4ae Fixes: cce2dbdf258e ("HID: uclogic: name the input nodes based on their tool") Suggested-by: Maxime Ripard Suggested-by: Dmitry Torokhov Signed-off-by: Rahul Rameshbabu Reviewed-by: Maxime Ripard Link: https://lore.kernel.org/r/20230824061308.222021-2-sergeantsagara@protonmail.com Signed-off-by: Benjamin Tissoires [ Adjust context ] Signed-off-by: Wenshan Lan --- drivers/hid/hid-uclogic-core.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 785d81d61ba4..47d88cd95fc0 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -104,10 +104,8 @@ static int uclogic_input_configured(struct hid_device *hdev, { struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); struct uclogic_params *params = &drvdata->params; - char *name; const char *suffix = NULL; struct hid_field *field; - size_t len; /* no report associated (HID_QUIRK_MULTI_INPUT not set) */ if (!hi->report) @@ -145,14 +143,9 @@ static int uclogic_input_configured(struct hid_device *hdev, break; } - if (suffix) { - len = strlen(hdev->name) + 2 + strlen(suffix); - name = devm_kzalloc(&hi->input->dev, len, GFP_KERNEL); - if (name) { - snprintf(name, len, "%s %s", hdev->name, suffix); - hi->input->name = name; - } - } + if (suffix) + hi->input->name = devm_kasprintf(&hdev->dev, GFP_KERNEL, + "%s %s", hdev->name, suffix); return 0; } -- 2.43.0