From nobody Sat Feb 7 08:06:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 51B502877DE; Mon, 26 Jan 2026 20:02:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769457768; cv=none; b=IOcbeTIrY14eJmjgt3YBsL1xOwb7tTjy/iYypoSkfqddALe2/Kx9BmRlSnR7p4cPXAUIBlSNSFuxUbmTfjDzqoj3tT1cJzhLGbQFiBYQ8fm6RuM5wGpzoAQMseBVPUr/bTh4c0cw8gB51vgWg9zLszsU2r36/gE3ARUAjfkuULo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769457768; c=relaxed/simple; bh=5fqLQlXhvk90yVheQPNcqn5k2uzKmq/uNH6lFCiBPsI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=KZXU9zLQ6eK8iFkzRRcJDnpWFwMGycjWrA0EaoXH+un0atlXPA2macl5oKsMPreOZ6iKfYWWEyr/A/oUFR2QTubptI0WR7EmyjL/ahe2GR/gbBeNERzpvTUL5LMJcMZtfIm5JJYBPv0cnzApKPmbDR+zxdzgEoSrZhIWVx7r5p0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O+sdBwra; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="O+sdBwra" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E575BC19422; Mon, 26 Jan 2026 20:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769457767; bh=5fqLQlXhvk90yVheQPNcqn5k2uzKmq/uNH6lFCiBPsI=; h=From:To:Cc:Subject:Date:From; b=O+sdBwraC8HD+KXEA5FWwNpADSBtD+6w2ktPdtzyf2noc2LEyhK+GPVoUyqtegN++ RnCtXr5XTg1aEXlkVogIkxhGtcMiIQAIfJW90Afcpgs08jqJMiUM/Fmj8SY69x0ohf fmEapzidUq56uouj2MTAljE63kxZbBx3jisbAjyGA52oprMu8Z5kBhBAw4xJw3GXQm E5l0HymFpJnMftOBMOjE5JhJkXV83GY2+QmZz0Z7vWHLvJZTgAO9aeX7FR3TE/mksf g3dXWwAnshyNd5Fwl0rW5O9QixLK53fVY6gjFwTJct3R6g7/GSH1NNZJ6I+f5jrl8R RAK2JW92CzyxA== From: "Rafael J. Wysocki" To: Hans de Goede , Ilpo =?ISO-8859-1?Q?J=E4rvinen?= Cc: LKML , Linux ACPI , platform-driver-x86@vger.kernel.org, Thadeu Lima de Souza Cascardo Subject: [PATCH v1] platform/x86: classmate-laptop: Add missing NULL pointer checks Date: Mon, 26 Jan 2026 21:02:40 +0100 Message-ID: <12825381.O9o76ZdvQC@rafael.j.wysocki> Organization: Linux Kernel Development 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" From: Rafael J. Wysocki In a few places in the Classmate laptop driver, code using the accel object may run before that object's address is stored in the driver data of the input device using it. For example, cmpc_accel_sensitivity_store_v4() is the "show" method of cmpc_accel_sensitivity_attr_v4 which is added in cmpc_accel_add_v4(), before calling dev_set_drvdata() for inputdev->dev. If the sysfs attribute is accessed prematurely, the dev_get_drvdata(&inputdev->dev) call in in cmpc_accel_sensitivity_store_v4() returns NULL which leads to a NULL pointer dereference going forward. Moreover, sysfs attributes using the input device are added before initializing that device by cmpc_add_acpi_notify_device() and if one of them is accessed before running that function, a NULL pointer dereference will occur. For example, cmpc_accel_sensitivity_attr_v4 is added before calling cmpc_add_acpi_notify_device() and if it is read prematurely, the dev_get_drvdata(&acpi->dev) call in cmpc_accel_sensitivity_show_v4() returns NULL which leads to a NULL pointer dereference going forward. Fix this by adding NULL pointer checks in all of the relevant places. Signed-off-by: Rafael J. Wysocki --- drivers/platform/x86/classmate-laptop.c | 32 +++++++++++++++++++++++++++= +++++ 1 file changed, 32 insertions(+) --- a/drivers/platform/x86/classmate-laptop.c +++ b/drivers/platform/x86/classmate-laptop.c @@ -207,7 +207,12 @@ static ssize_t cmpc_accel_sensitivity_sh =20 acpi =3D to_acpi_device(dev); inputdev =3D dev_get_drvdata(&acpi->dev); + if (!inputdev) + return -ENXIO; + accel =3D dev_get_drvdata(&inputdev->dev); + if (!accel) + return -ENXIO; =20 return sysfs_emit(buf, "%d\n", accel->sensitivity); } @@ -224,7 +229,12 @@ static ssize_t cmpc_accel_sensitivity_st =20 acpi =3D to_acpi_device(dev); inputdev =3D dev_get_drvdata(&acpi->dev); + if (!inputdev) + return -ENXIO; + accel =3D dev_get_drvdata(&inputdev->dev); + if (!accel) + return -ENXIO; =20 r =3D kstrtoul(buf, 0, &sensitivity); if (r) @@ -256,7 +266,12 @@ static ssize_t cmpc_accel_g_select_show_ =20 acpi =3D to_acpi_device(dev); inputdev =3D dev_get_drvdata(&acpi->dev); + if (!inputdev) + return -ENXIO; + accel =3D dev_get_drvdata(&inputdev->dev); + if (!accel) + return -ENXIO; =20 return sysfs_emit(buf, "%d\n", accel->g_select); } @@ -273,7 +288,12 @@ static ssize_t cmpc_accel_g_select_store =20 acpi =3D to_acpi_device(dev); inputdev =3D dev_get_drvdata(&acpi->dev); + if (!inputdev) + return -ENXIO; + accel =3D dev_get_drvdata(&inputdev->dev); + if (!accel) + return -ENXIO; =20 r =3D kstrtoul(buf, 0, &g_select); if (r) @@ -302,6 +322,8 @@ static int cmpc_accel_open_v4(struct inp =20 acpi =3D to_acpi_device(input->dev.parent); accel =3D dev_get_drvdata(&input->dev); + if (!accel) + return -ENXIO; =20 cmpc_accel_set_sensitivity_v4(acpi->handle, accel->sensitivity); cmpc_accel_set_g_select_v4(acpi->handle, accel->g_select); @@ -549,7 +571,12 @@ static ssize_t cmpc_accel_sensitivity_sh =20 acpi =3D to_acpi_device(dev); inputdev =3D dev_get_drvdata(&acpi->dev); + if (!inputdev) + return -ENXIO; + accel =3D dev_get_drvdata(&inputdev->dev); + if (!accel) + return -ENXIO; =20 return sysfs_emit(buf, "%d\n", accel->sensitivity); } @@ -566,7 +593,12 @@ static ssize_t cmpc_accel_sensitivity_st =20 acpi =3D to_acpi_device(dev); inputdev =3D dev_get_drvdata(&acpi->dev); + if (!inputdev) + return -ENXIO; + accel =3D dev_get_drvdata(&inputdev->dev); + if (!accel) + return -ENXIO; =20 r =3D kstrtoul(buf, 0, &sensitivity); if (r)