From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49DA736AB58 for ; Tue, 17 Feb 2026 16:01:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771344106; cv=none; b=T7q0PbXsXfqzMzIIw1652BzJgeNfVZIGoKjDXp+VpEO5nHlo0FMIOUtcp5eOgPgiIv9IRBBys57wnVLI8Alz9H5g1EjQw9gjIL8+vEZbluwZYuOXFD8mcZvVQh9/F67WRJm3VoCa15y0sAf5Vg7eSYh/rgNoqOjUl47F3mgDjBA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771344106; c=relaxed/simple; bh=iHmZ4x5Vn0J649Q2pkliTeC1eYINFiSsHq8vKWdGDDE=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=oGghMLljbHBXjpex1oGAbSsSyjYpsU8fRQzTTbBbRW0NaTEgNvPsxVeuLFg/RfTQVUSSAnbq6EHotJHAgA6As8x8vIB5hj2f0RnrS4dGUpHBsJuhfbOw4lFjZptYj8hy06rTFUbHKQyH2lIxrkKJfOvaa2G9kEmYOfpw/OWrfIY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--gnoack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=PDUaOtSe; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--gnoack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PDUaOtSe" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-435db8ebc98so4186657f8f.0 for ; Tue, 17 Feb 2026 08:01:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771344103; x=1771948903; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=qnRh0lA3B1U30SyK+gpMCmGhg6iwBc2oClXC6RFEEY0=; b=PDUaOtSeZhkokyiiAJmO2wj/w5y3TpzvNfAAreHpmgAFerUnH0LhEncvQmH5z6oV5D E2ET9o33zDlIWoNnHPhDeGENbWf+b+GCwPpEIkbE2zmlX4D+MW7/c8TDGlnO0uGyc52s XATVsdj4fEopwiZV2JRuJ9z6Xb0mx+Z3Ftz/O7GStO1JwLIqdNlsUXApwKoV7L0Mo9n4 Ykg8byfLQrsDfP3X5QvazFgne+eGV6XNTkbNx81L+xff6o1KDIW3cF2/POojhBAwx8hh xTeJLNR+zSKefw4JTFbtJ5fvWqD0Yd2+WaRvMp2tL0Nh5cisgpKWklR7Ae9fkr3ixK91 W1xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771344103; x=1771948903; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qnRh0lA3B1U30SyK+gpMCmGhg6iwBc2oClXC6RFEEY0=; b=HtetL1g4zIuyK7uLfsG54oM8P2K3n7DNhg1IzTA3NujaMcwtW1R4UGtS5ufi5+63Wr tBTimuvnApiLLvg5g5qb15W1H7jsAT1ixNiztsD4gyQt2u3lF5AFdA1LyIZQcCTcGcyJ Dm8UrCw9XFK4nnHheGMdNL3w92IXRHUzP4Z7GK2cIzkLnBXk5WVF5ZsptiLNSt2QvFbQ ALHpf18tqcqNGIsoNzpLmHxDs8Wb2rE9JtDR//U7npTGyKIIxCbi4FCD0gbwSFwFY466 fIcQwPOg6ZBfzP5L+hTBhjsQWVXltmf1HtSlc4jo4Gm4GmCiSyYfiVXT4rAZPP1jV04H IAgQ== X-Forwarded-Encrypted: i=1; AJvYcCXz73ou9iIFHlUGA5TRo1i1QTXMAWu1h5VDcjCCy5zRY+2ipo/iUv3nQSUZ2RFVElhodsKqLYc+H+QItmM=@vger.kernel.org X-Gm-Message-State: AOJu0YwgQalz0NirgYKu95+KSiByC/8J0kzruNdwyM0pxdRB1H4jRjSy LEvOkRlbBMqY3GlUlXz+VPBOAE0jivy9TtdclS8UjsDfmxhvyhFXVaB+gbMRC/D8r+fbcxPB1m5 RTejR3Q== X-Received: from wrtp15.prod.google.com ([2002:a5d:4e0f:0:b0:436:198:b7af]) (user=gnoack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:2403:b0:437:75c1:578d with SMTP id ffacd0b85a97d-437978c792bmr27445209f8f.11.1771344102413; Tue, 17 Feb 2026 08:01:42 -0800 (PST) Date: Tue, 17 Feb 2026 17:01:22 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.53.0.335.g19a08e0c02-goog Message-ID: <20260217160125.1097578-1-gnoack@google.com> Subject: [PATCH 0/3] HID: Fix some memory leaks in drivers/hid From: "=?UTF-8?q?G=C3=BCnther=20Noack?=" To: Jiri Kosina Cc: Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, "=?UTF-8?q?G=C3=BCnther=20Noack?=" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello! These patches fix a few memory leaks in HID report descriptor fixups. FWIW, a good ad-hoc way to look for usages of allocation functions in these is: awk '/static.*report_fixup.*/,/^}/ { print FILENAME, $0 }' drivers/hid/hi= d-*.c \ | grep -E '(malloc|kzalloc|kcalloc|kmemdup)' The devm_* variants are safe in this context, because they tie the allocated memory to the lifetime of the driver. For transparency, I generated these commits with Gemini-CLI, starting with this prompt: We are working in the Linux kernel. In the HID drivers in `drivers/hid/hid-*.c`, the `report_fixup` driver hook is a function that gets a byte buffer (with size) as input and that may modify that byte buffer, and optionally return a pointer to a new byte buffer and update the size. The returned value is *not* memory-managed by the caller though and will not be freed subsequently. When the `report_fixup` implementation allocates a new buffer and returns that, that will not get freed by the caller. Validate this assessment and fix up all HID drivers where that mistake is made. (and then a little bit of additional nudging for the details). =E2=80=94G=C3=BCnther G=C3=BCnther Noack (3): HID: apple: avoid memory leak in apple_report_fixup() HID: magicmouse: avoid memory leak in magicmouse_report_fixup() HID: asus: avoid memory leak in asus_report_fixup() drivers/hid/hid-apple.c | 4 +--- drivers/hid/hid-asus.c | 15 +++++++++++---- drivers/hid/hid-magicmouse.c | 4 +--- 3 files changed, 13 insertions(+), 10 deletions(-) --=20 2.53.0.335.g19a08e0c02-goog