From nobody Fri Apr 3 04:49:59 2026 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.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 2411F338F52 for ; Tue, 17 Feb 2026 16:01:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771344111; cv=none; b=KkkW40T8llkJtYNqzaaSFBEHkVA0WfczqoLoDKepXyLa0L18CLU7QavVrVH8hz4S6PDxK1NV+1dlsDNQ1G8yFQUNENlp9MBIXjtTL9aCJyUxNDNjM/nfn47V8mm6rzSzL6hAL5PxRXrgSAQqXIrLHsH18WtodMbIL2do9cyJbkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771344111; c=relaxed/simple; bh=Ud+XGMu6AkUW3LrlHDAURXAUgcp23XINbGFrcaqaYuk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=kernEj2FuyLqtDe9PEdBsrltX0fVaIrs3F3RMzco3g4wrk095D3qqGj7bYmTVLqTSikUc+7xAts30zh6Q1nj0WbMJe5AoBGeb8xerK+3LbVj6y2LtJln8hhh9gcF3fFtsB4uXSryk7mm3JeSdHSOB40TL0HvxdpjhEtMDSx7lyk= 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=BPLEQldn; arc=none smtp.client-ip=209.85.128.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="BPLEQldn" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-4837246211bso46656225e9.0 for ; Tue, 17 Feb 2026 08:01:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771344108; x=1771948908; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=Rbpj+Bbkqn2IuTm32qCsXgbOnINoBejA1Y9YI9+bl8Y=; b=BPLEQldnfQSdm860fEHIY3FC3qFsqByp+yBSxp2hhD1bK9fmk3G7TdwWR7+G3HGzyD hPvzJDaw7P41qf2h9NFwkcq/DlxR/k7YAQzmgMSVkuUDBTWYXoq6yopSObiVQNNMOpRX C8ZCyCChSJiMWZOk2R2kwR93cQHQqeEeFZxWFOPZj4cmVDPwdLsovaf0nuCa6hDNFcNN Dm+grNc/0B3gYgiOvPjH6QW+rUvu5l4xLtM5pWgkTZbHjuSVX947Eqt1uPVAZI6tVGSU 4uQSijL0pbFiUn7VXdZq738kQJagxcYnebhU+7FM3F9pujbvhvXEv0pwCNDtXlV/CeKu eiRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771344108; x=1771948908; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=Rbpj+Bbkqn2IuTm32qCsXgbOnINoBejA1Y9YI9+bl8Y=; b=R05JrRAj0/5V/xVXoYJR+rupgaq488miFcEcKCTNjPl3yQEyZoeBotzJw5B66B0fgV 2DSpp7dAWXN34sYWHLWqMa3Emhl0nalJ7KmDJyBeKYLUdLwmiNT8Cl0igqeG1Ip0qklg eAYQqzxQCfFpjzbRGRN3v4m6DJkiJt1pV2dozUKxtJuXNw8mLdWkLFfO7yNLiJtoWwJX 7SpJ7fjGzdLhHc+novPDEmt/g/IeKp0t+x1X0cBv/NBx+rVXwtHSw9waXFHmp1YcTPob 7jWPSGLlBijPX/WqQ5VX95lA1T2xenk+X9bdhLAD17B6MjAZqUDR+8kuyjeKNUiQfUcC 0iOA== X-Forwarded-Encrypted: i=1; AJvYcCWFpMEMbh5uraRfepZ6eOMi+q/UUXDae1GOu1Xv6COWncrDw7SJd+suusKpGNI0H2NSMyZLeMaVLUdL3uI=@vger.kernel.org X-Gm-Message-State: AOJu0YzJJ6o81WapBxkbt1lgUquDDlNqR0wdFenDI4gpJBlyKJk23xCh YIEkaIYJm79nQ2rYYjjXAgg7ucpf5NMvcmlW1axJD9irdHFOkzcE+szFd8pAYmYdaOfWjTGT17g cgaYLRQ== X-Received: from wmhi21.prod.google.com ([2002:a05:600c:14d5:b0:483:6e28:c182]) (user=gnoack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:3496:b0:477:fcb:2256 with SMTP id 5b1f17b1804b1-48373a5ba90mr245605825e9.17.1771344108136; Tue, 17 Feb 2026 08:01:48 -0800 (PST) Date: Tue, 17 Feb 2026 17:01:23 +0100 In-Reply-To: <20260217160125.1097578-1-gnoack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260217160125.1097578-1-gnoack@google.com> X-Mailer: git-send-email 2.53.0.335.g19a08e0c02-goog Message-ID: <20260217160125.1097578-2-gnoack@google.com> Subject: [PATCH 1/3] HID: apple: avoid memory leak in apple_report_fixup() 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The apple_report_fixup() function was allocating a new buffer with kmemdup() but never freeing it. Since the caller of report_fixup() already provides a writable buffer and allows returning a pointer within that buffer, we can just modify the descriptor in-place and return the adjusted pointer. Assisted-by: Gemini-CLI:Google Gemini 3 Signed-off-by: G=C3=BCnther Noack --- drivers/hid/hid-apple.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index 233e367cce1d..894adc23367b 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c @@ -686,9 +686,7 @@ static const __u8 *apple_report_fixup(struct hid_device= *hdev, __u8 *rdesc, hid_info(hdev, "fixing up Magic Keyboard battery report descriptor\n"); *rsize =3D *rsize - 1; - rdesc =3D kmemdup(rdesc + 1, *rsize, GFP_KERNEL); - if (!rdesc) - return NULL; + rdesc =3D rdesc + 1; =20 rdesc[0] =3D 0x05; rdesc[1] =3D 0x01; --=20 2.53.0.335.g19a08e0c02-goog From nobody Fri Apr 3 04:49:59 2026 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (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 CE40A36C595 for ; Tue, 17 Feb 2026 16:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771344118; cv=none; b=jl9Jav4bAhdgVPT3xf5Mu04m7UKE1432zmny5H5Apx9IGXNn4NuEtIfTCMZOzQIPLgu7ZyJOhAFoqi/JDXSLpOubYCXbd3HPc0xeZE+PD6U5rki+ejcCwSRwi05j5vHy0tZ6tLxgZa9dhdrSmzSD62cvqkwTPzGGrvlzCO0niuU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771344118; c=relaxed/simple; bh=Pz4lfEfYS4nyE/SQUqp3w27aSTJnY160w0WTT8a8SnM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bcAdBOrZKpjl4lTP2WjxP4LfUMqSkEcoNrpkqbmRcZ/+WTbWK0oNMLFi34rbDoPDAub3ssOnLj2fMvyKkKVudKIxWJZwB7GmP+CZFMFtddTpdb9pwaZtPWvTDG02xeVz1h5uKnL+EYo6V3ebKlhoSier/IVYTcIT/vyPMlUFXrQ= 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=FKalUF5i; arc=none smtp.client-ip=209.85.128.73 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="FKalUF5i" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4803e8b6007so37350155e9.0 for ; Tue, 17 Feb 2026 08:01:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771344115; x=1771948915; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=vmHbHptT/xQLvcgY8qMF4oxcaID/3KLnmaRfPxMJwO0=; b=FKalUF5iO9+SSJphELBuNcNCB/8Mf/OBTBYb6GwzGyp63Mtb7Ka6r1R6iBUyaDxs0v vsboTvUUdqpw9CRpiiwGQPVb06TR4gXzPg9kkEL6KjhMYnf3VOTLgfYn0764GSB0mf8s f1wCTbke0g4fINm58ztaFg3LSk/XH2w3MTwJTT7b8PrGGU2a0cmIAa0X+4cwUWc/EAvP oQEHm0Chm0q6b37/rTRM2wzrXUn3P04eo0od1AoRD2RIn9YCzmlfUnCuBwytsRkQY763 VoQ9pGDdSOpeqO38OM1gjXNTT1KQlKBUWMo0+9i8ZEEE3RkV6h8NjiNKa7vd/hLnM3CN UY5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771344115; x=1771948915; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=vmHbHptT/xQLvcgY8qMF4oxcaID/3KLnmaRfPxMJwO0=; b=kFvNScw1hcYA5W0qQGNu47n/9+NcfqOKksgffz2y8n+yfEz/MkTQ15Yf+liG9dLZ4H 0/iI+IdvFW1FWU+pElWew5gjtMPqIgoMiZ513Q1EAfhxk6Io2EvTvM+JiYJiwrHUEI0d Qyp5ladbX6YmqjL+abUI6oEI5G9ch2IpljeY9U4f5fIvoYJ7AQ8osuSXZUs/tkHnqMCG zd08wvVX7QPgpoeFlUUgq7j5Kd2XhXcE+ugJ7BND/+ErL/gAzo+Pk2mdTP4e/Xl0Ulmq rn9ljSKN8Rq2saTpZv7nI0gn3t6qA4VwUvGxo9RK4O6DITjwDJZ73/ulqxVlg0ZEu4um 565w== X-Forwarded-Encrypted: i=1; AJvYcCWQ5pXDN2b3LarYDdqqNwLSL57CXwj9mAvmRyb7P/5L/VVcgw/0QAr2yrHzdO4Th88TA+8ZhxgmK2J20Vc=@vger.kernel.org X-Gm-Message-State: AOJu0YyVSKXQbJFw/UbN8DRSQ8hFdFywug9pmthBJbHGiFzLbe+CRtt8 NrtK22G6n62mFepRmpnDO9d5T/0ay8UktjKOyh+dTITVd0HRVxfsV7O4liJQPVMQewTh0SA2Z1x 0P2nLqg== X-Received: from wmbhc11.prod.google.com ([2002:a05:600c:870b:b0:47e:da9a:d7da]) (user=gnoack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:1907:b0:479:3a86:dc1c with SMTP id 5b1f17b1804b1-48373a7a0eamr239685595e9.36.1771344115180; Tue, 17 Feb 2026 08:01:55 -0800 (PST) Date: Tue, 17 Feb 2026 17:01:24 +0100 In-Reply-To: <20260217160125.1097578-1-gnoack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260217160125.1097578-1-gnoack@google.com> X-Mailer: git-send-email 2.53.0.335.g19a08e0c02-goog Message-ID: <20260217160125.1097578-3-gnoack@google.com> Subject: [PATCH 2/3] HID: magicmouse: avoid memory leak in magicmouse_report_fixup() 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The magicmouse_report_fixup() function was allocating a new buffer with kmemdup() but never freeing it. Since the caller already provides a writable buffer and allows returning a pointer within it, modify the descriptor in-place and return the adjusted pointer. Assisted-by: Gemini-CLI:Google Gemini 3 Signed-off-by: G=C3=BCnther Noack --- drivers/hid/hid-magicmouse.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index 91f621ceb924..17908d52c027 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c @@ -994,9 +994,7 @@ static const __u8 *magicmouse_report_fixup(struct hid_d= evice *hdev, __u8 *rdesc, hid_info(hdev, "fixing up magicmouse battery report descriptor\n"); *rsize =3D *rsize - 1; - rdesc =3D kmemdup(rdesc + 1, *rsize, GFP_KERNEL); - if (!rdesc) - return NULL; + rdesc =3D rdesc + 1; =20 rdesc[0] =3D 0x05; rdesc[1] =3D 0x01; --=20 2.53.0.335.g19a08e0c02-goog From nobody Fri Apr 3 04:49:59 2026 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.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 4ED593612C5 for ; Tue, 17 Feb 2026 16:02:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771344123; cv=none; b=cnJ8nKyH8GAivBhUsKu614YwvbxUCdnIP0zoZK5ico++HN0Q/mvB/TkscMjBTGFcBz+cek658eP/Par4GGifdEXrUiw6Ab8yiFZt7v3J+zwb/S4HYRE4d96CyyfgMxUXggwCve8WNaEMI+cKgTP74XwwqSaupDAH7cz8QwgqCwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771344123; c=relaxed/simple; bh=6wHoJGPxc/bgsQgAP8SAdyvzO2Ye//4fEtok06MhYu4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mkCI8uP/MdgtT5f57Vru0t6xB2ZAliVtI1o3odx5UyzhpxpcLeRSJwbwgsdy07Bcvrrjj47cGjO2CXejGelkujV2EaejLuQykZTRJvQQuLuQR+HDnj8gAMbkok33DAT7OY4u1dgGo6ElIbzHD86Zc8Ab0iBmqUICaJYfhJ5Foyw= 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=EvtiU8si; arc=none smtp.client-ip=209.85.128.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="EvtiU8si" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-4837cee2e9bso25148855e9.3 for ; Tue, 17 Feb 2026 08:02:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771344121; x=1771948921; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=ZZSEkVlDQEEWi12zs5UutmmvJgsLSopiUv13OQwX2PY=; b=EvtiU8sicQp4ESuA9LHkpoh6p24f5b/MYNFQvRXzTLM971nOtyOw6sjBxSAEM3TWE0 Nv4vRT4Ful24sjq+3KVfCCD+GjR3js0inocQzTAGKKMLaNAX3ZpviyLDFKD+W3UwADSS xWOWDOSeh5X1WDe1g4mCNQl2Hnq17BI0QXDz/ZE9VxR813U8plCckDCSogvDR0vL1G24 uTbKL2LNQMjV6f4d2i354NsN5xpDiwz05BqtsHAsTA9t7Gn9rQ/nHOIPDMvpsjtgyFIN xbRDoBVvyOn+wpRfJ1FY16J3mx5k4gF/uQ/cGbDyy+WyOcl8mPHwvRUTSQtb2wNZR4// Zz0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771344121; x=1771948921; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=ZZSEkVlDQEEWi12zs5UutmmvJgsLSopiUv13OQwX2PY=; b=gpR0KQIdFuDUcK8lksm4ZP5jgI4wK+1SWOoJLA8sKauhV9f1/TM3otv98uEu+ImQF7 E47hm2UgaCpQpADUOvaNerwqWSdhLvzfI8mzdeoocEFuyfsrfV8IM51sIpXJAk6Fl6wy 3Q06jJ1HvEy8uR3l9PgD8eGtyXrn3ysDl8U516S+rsZkR788CkQ+9/pn2Qgqazx9AL4l NZXcuYHZFNRpbhSYUnBEiiLgLIm1yy1XSya3Bjh0hBuRvzUMLAvcpguDqDYY5C52QIFA 28QK4rwAlkNOjQX0VzIDbasVtjy2THb8qWrR/hm8Pkf5uhWTV2YcP+d3aZk0hd9usZYz EsJA== X-Forwarded-Encrypted: i=1; AJvYcCVW8qP2T5c7DPJVQUe87OeegWItjShxNwpZ1UO4nEC31jICXgqE+3e24abdj2GAgLYG3zoDPKlZlrQz7mA=@vger.kernel.org X-Gm-Message-State: AOJu0YxKUEYOTag+4rvg/wLQDV0OIRePxiI/VipPjSRfKxL1Msr9UHyY SFde+gEKbsZlRbHK7SCiMkXn4SQhBwV0SJ6WN2Cm/yuzhjUJQvQR/XRSfDWLIGjKJpgHmgWJDVz GXkeXCw== X-Received: from wmbjp17.prod.google.com ([2002:a05:600c:5591:b0:483:26c3:383e]) (user=gnoack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4443:b0:47e:e952:86c9 with SMTP id 5b1f17b1804b1-48379b318bamr165159675e9.0.1771344120458; Tue, 17 Feb 2026 08:02:00 -0800 (PST) Date: Tue, 17 Feb 2026 17:01:25 +0100 In-Reply-To: <20260217160125.1097578-1-gnoack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260217160125.1097578-1-gnoack@google.com> X-Mailer: git-send-email 2.53.0.335.g19a08e0c02-goog Message-ID: <20260217160125.1097578-4-gnoack@google.com> Subject: [PATCH 3/3] HID: asus: avoid memory leak in asus_report_fixup() 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The asus_report_fixup() function was allocating a new buffer with kmemdup() when growing the report descriptor but never freeing it. Switch to devm_kzalloc() to ensure the memory is managed and freed automatically when the device is removed. Also fix a harmless out-of-bounds read by copying only the original descriptor size. Assisted-by: Gemini-CLI:Google Gemini 3 Signed-off-by: G=C3=BCnther Noack --- drivers/hid/hid-asus.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c index 8ffcd12038e8..7a08e964b9cc 100644 --- a/drivers/hid/hid-asus.c +++ b/drivers/hid/hid-asus.c @@ -1399,14 +1399,21 @@ static const __u8 *asus_report_fixup(struct hid_dev= ice *hdev, __u8 *rdesc, */ if (*rsize =3D=3D rsize_orig && rdesc[offs] =3D=3D 0x09 && rdesc[offs + 1] =3D=3D 0x76) { - *rsize =3D rsize_orig + 1; - rdesc =3D kmemdup(rdesc, *rsize, GFP_KERNEL); - if (!rdesc) - return NULL; + __u8 *new_rdesc; + + new_rdesc =3D devm_kzalloc(&hdev->dev, rsize_orig + 1, + GFP_KERNEL); + if (!new_rdesc) + return rdesc; =20 hid_info(hdev, "Fixing up %s keyb report descriptor\n", drvdata->quirks & QUIRK_T100CHI ? "T100CHI" : "T90CHI"); + + memcpy(new_rdesc, rdesc, rsize_orig); + *rsize =3D rsize_orig + 1; + rdesc =3D new_rdesc; + memmove(rdesc + offs + 4, rdesc + offs + 2, 12); rdesc[offs] =3D 0x19; rdesc[offs + 1] =3D 0x00; --=20 2.53.0.335.g19a08e0c02-goog