From nobody Sun Feb 8 09:22:50 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 DB6D71DF273 for ; Sat, 15 Nov 2025 02:23:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763173410; cv=none; b=CKtinGZA5MBlseILaD7e8HwHL133h70m8dKiN6TSG1KBmrP9nVEWjMjF6jaqkPSJc/UAQ/sHEQXOq7TEW9NTjJE0TAN1WmrRG+jd7hYJH8DYmPxVH0dCQjxSv8iuxMN9LEfJ0r9VjHEmMwihLKV5PFAeEKBMRL/3CPpz5VeM4Tg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763173410; c=relaxed/simple; bh=PDuIwqkmp4oY++AO5WJEFu5LTrqlYcDohavau5UgJBw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tfKlJahhbjfK+u/UQgublpp3GeOPAQpfYnFsHSv3TETdGHm5dzSOPe21/6ioPi0/QQkQvlO4s9BwBw6IC4q6z5eCfggTx550C0IMm7oUnBsRf+O/6J9zqhYD1tuCSgo1/0/+xaERz6rmJoAWDmqA0n6f8M0slN7rgNF8EcdXL5g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Dzx35Vfs; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Dzx35Vfs" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-477619f8ae5so18212155e9.3 for ; Fri, 14 Nov 2025 18:23:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763173407; x=1763778207; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Yq39x51ae6KSXgKlBMN16r069fnAu1T426yuW0a275o=; b=Dzx35VfsIyfoXs4YE+h4D5y1h1M/yPItyo4RBnM/HNXfNmEovEx5vGdCu54mGvVqsp skplMTFmaHbLaywz5fv44R+MhCJDnZw2FtqP8Bfd4o3K2pUtrm89Kxky6iA7Q/BgP6rm XunPXn193lhY1Z81W1YyyI/475GrKDDxrXwrZI90HpJ/XguceCnguruoFWWKneBMgczB tVrC8hkZ96BMMe/TIr8PHR7IdweCr6QxJ6um2NpxNatgP4c8Sh6WxrZNDvKIV7K3zjFe Hqw+MAnqZKc3KkwENloSKQaVfXYlbvotia8LU5F5A0jxGHUPCao/1XfH7d+GfKE62OPP cUxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763173407; x=1763778207; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Yq39x51ae6KSXgKlBMN16r069fnAu1T426yuW0a275o=; b=RB8lM7buDTECuEXmsvCqnRdv7CMkSTltAstbkuv3yyxhe/cR4z5UDFs+HG4MXesHI+ CX+Nd2Atqu34lNTMZTG+/i1PX/pmKkmU9yxqVIXotwR011xYO/GJLoSqA4RiqZvwDXCY Ts8l7OqxDrGa75UQAYWW4wqa7se9UGEJWWoo98L9/l7aMC1wQ16Ghsxlczq/Qwt786wN v4vRKP+S87dgA1WzM1TJpSBRpnDlEyBSxZ1JJHBRkP4nfMdmgfUJ1QVpWFuLL6pMVvaZ bUwZBwDEvlgVjLcSBYzXxfQoPTS16/7hasBacgvK/hM/ntqm/xvBXqrQXysNRfgtvIQd rE9w== X-Forwarded-Encrypted: i=1; AJvYcCWLBNxrous4Ksk6zQsSrxz0ckCE0MGzR5YcH9td2F6vOQSypewRkcEvHFJscqb5XkIqi1UC47fX+Clxnxc=@vger.kernel.org X-Gm-Message-State: AOJu0YwiKwEtC8No9YJlxkC0kprer90TpThVkulXWGfF44uzbDdoTteh KfgETM6rCjjcd1EZpzqZfw7npQsAfqWU4fV//JFN/irSzTB9wefus0r5 X-Gm-Gg: ASbGnctVeEOLBQfgGcUpmDeINDLZDMm+dzdxTWxd566qvLcDoXn3igSw3dVt8VtN3ll sHe1wFNr6zksmoI+Azf7kpT1l4SAquRkuhuxMz0ZE4vEnxZ/ciS7VieaW03a/XFg6FMrv2IJ0pq 8DjILha0W3jqwDStB0PQhGW6OvgkmdPYMYGQk4jAgaTYzRsolUgD+4iBQ5pl4XG0NaGuPIMldrz gKvmENvM6ekZ9b/kwj42VMvfE4pQVZOmZ4yjkyDv0nvRmOfpGFiiAysPY1Hi9WVfrpjv/a1LsL/ /ZLRetCHd3HxMmlPlucBzPVdH/ZW+2lY9Fw5yA79n4lleL4MjxHL4OP3LpmVOHGlcXF49re0E6R fqx1SuAWMSf6o+LTM2cqYZrNNsnG7cBzqW/2PbNvq7/ezhGh7smhjYVd3Uo4Up69iAWdCB1g776 igJM6Si/mrR6qvfUauTQ== X-Google-Smtp-Source: AGHT+IHwtds412uhUupLtmV+2/NGIul99ockQiTr5w6D0rYEzcLwFACKDUNxLF2QbUdnIpMPXMH43g== X-Received: by 2002:a05:600c:4695:b0:477:63b4:ef7a with SMTP id 5b1f17b1804b1-4778feaa8a1mr40105145e9.20.1763173407164; Fri, 14 Nov 2025 18:23:27 -0800 (PST) Received: from ekhafagy-ROG-Strix.. ([197.46.78.60]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4778bcfbaeasm56157495e9.9.2025.11.14.18.23.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Nov 2025 18:23:26 -0800 (PST) From: Eslam Khafagy To: roderick.colenbrander@sony.com, jikos@kernel.org, bentiss@kernel.org, max@enpas.org Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, eslam.medhat1993@gmail.com, syzbot+4f5f81e1456a1f645bf8@syzkaller.appspotmail.com Subject: [PATCH] HID: memory leak in dualshock4_get_calibration_data Date: Sat, 15 Nov 2025 04:23:23 +0200 Message-ID: <20251115022323.1395726-1-eslam.medhat1993@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" function dualshock4_get_calibration_data allocates memory to pointer buf. however the function may exit prematurely due to transfer_failure in this case it does not handle freeing memory. this patch handles memory deallocation at exit. Reported-by: syzbot+4f5f81e1456a1f645bf8@syzkaller.appspotmail.com Tested-by: syzbot+4f5f81e1456a1f645bf8@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/691560c4.a70a0220.3124cb.0019.GAE@googl= e.com/T/ Fixes: 947992c7fa9e0 ("HID: playstation: DS4: Fix calibration workaround fo= r clone devices") Signed-off-by: Eslam Khafagy Reviewed-by: Max Staudt --- drivers/hid/hid-playstation.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index 63f6eb9030d1..fef81b7e27c1 100644 --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c @@ -1992,9 +1992,6 @@ static int dualshock4_get_calibration_data(struct dua= lshock4 *ds4) acc_z_plus =3D get_unaligned_le16(&buf[31]); acc_z_minus =3D get_unaligned_le16(&buf[33]); =20 - /* Done parsing the buffer, so let's free it. */ - kfree(buf); - /* * Set gyroscope calibration and normalization parameters. * Data values will be normalized to 1/DS4_GYRO_RES_PER_DEG_S degree/s. @@ -2041,6 +2038,10 @@ static int dualshock4_get_calibration_data(struct du= alshock4 *ds4) ds4->accel_calib_data[2].sens_denom =3D range_2g; =20 transfer_failed: + /* First free buf if still allocated */ + if(buf) + kfree(buf); + /* * Sanity check gyro calibration data. This is needed to prevent crashes * during report handling of virtual, clone or broken devices not impleme= nting --=20 2.43.0