From nobody Mon Feb 9 01:45:07 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 8EB917E792 for ; Fri, 26 Dec 2025 22:31:08 +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=1766788270; cv=none; b=apGsLGvnj0mx7knFMOvR5skKIIGs7nXipxLgJDlglviwSuxlJ7cSOOUh7pkyiNvE3YWHlJxk3vVavNSbi0suimTpb0HZxiKZyOnwaznSbofeKzRdhAx5iYs358nWUo7TBz4I0MsDwJx9UVm4YqlVsbbCsPNsHoaXGhMlgzCukHg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766788270; c=relaxed/simple; bh=K/7eMZxfEHX7vo68xSNfuDo9aAU6+thzgJeaK/X+ydU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=sx6SRZ+JSCvH37o+YNhAQEx9BLDFJjdjLY465PnNLXX1/L++CkByiQGW5pea9F+O/PxxFBLv+DIiOcF/ea/pTN/YdiyHMF5VDus0lYHil+1lr3p1EFXXHHkEMNNyawc0gy0o7wZ+A1rrm1Qc6A+cCgDg7bNz0d//b2YxB/h1hWY= 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=WEJErnLq; 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="WEJErnLq" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-47774d3536dso59314425e9.0 for ; Fri, 26 Dec 2025 14:31:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766788267; x=1767393067; 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=kYhKsfmKyRLGYUKXgcmzYEyxmyTNayWLcnyCustFjdM=; b=WEJErnLqyLPLqPMyIZ7UPv/lwvZn37gIHEaFxObx3xuOWs243E1lPkwdsh0pu3ymIi WXrphFA6Lcp6SAEGr3/7aEeDj5WVYteyWIMlShiC96Y3uqfWr3bPJcV7CSyIYt4qjyf6 8wou7caQc2LmxctvfJx4JKgAN7EKYyEYolIPgDwOtBM7g9+LrVZ2zPwS+RQwH94sHcfa Jehfpdk/vIIrs4NjxzMtnvB3mZuAuvHwnr5IpQfbAYdSEBiH2HZ2Oj37HqDBdCC+OtIa hkzFsuP+HaWY0YrHT5LvNxHcP8bl51JJVYT+b6r3MW3R9e7Z6wr+vnCg4qZ0kFZvK4bP Vv9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766788267; x=1767393067; 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=kYhKsfmKyRLGYUKXgcmzYEyxmyTNayWLcnyCustFjdM=; b=DNXI19celdXTVdF4Gjhs9/Tg/FfrXkdN2cC561pyc+hpgqez1XID8KK8EEr3AXwY8Q o0yOyBl/w8Z8v7sLyxYR+Aq/sl/FOk76hZrJuQaW/ISgsVO9wDMluzzLF88aJwQNx5/l fFnPHT5EnV5K2llmeSVEDiZEvom9tuAvX5O376OQSK0qdd0PShAyP7BwpddaqbbcxA2R IYKcLMXRkdrRXuAwU5PVtwS0y74CUS+NQgLhs9+jHDBYQot7uIS333PmEBODYJYFSPG8 nquUUiNtrz72gzGaV89od9BpgqDwCawGqE1iHcHRq06HZfUsVOA1d3Z/BLGsCZhFxlf0 piPA== X-Forwarded-Encrypted: i=1; AJvYcCUFzMznAyIipytvG5znHw8tGlCxUkm14c/W94dk3ifWhgl/U2JGa7RurATpyqZuOWLSO4GXigIrSn/VDKE=@vger.kernel.org X-Gm-Message-State: AOJu0Yzga0T/W+ph01SPSGXDoMxhr0760VfP2krbIa5CU/TmpzMjo9eE 4iBuRV+weFskVB6/2l2XxeSQ10mcIPI0rc5n5TQ3yKdoBzw8Nxw2Xs5c X-Gm-Gg: AY/fxX6P5VHyZiUMlbjDNUms5xaPplA3pjsAVPa/1o6biFFa9YTgvhXZlK8SEUyyyGa xXxVLN28GXa+S/J/jdbnezKujbWzRd4UpsWpAsyXvt8eVe0CdxOZ+Ccj+gvZOfYoSEI6Lj1ED+9 PaXJ+4wrHFp2wPsM3tr6Wzrha7An/ZVKoz2jKpQsFJvJoMdO5PYuYcB3gCRxyJ9gTrtZWbGzBAx +O9O2oeJMaBIf+EUJDvEkID0D3L7i6rx2oxZY5ttcuW9cbs3FYMoYmTkpOZJPRRmkzu0JJu/dfK iU5QJVFlW1CRTNNUakU2UR1GpmCdkv5qWkiOZdN2ZcwVQyP5o4pgDFThmX8aAPJx7DR3iQkgfPD LwHV3D7mjI5BEpONzMUTg3GRcfaiLB/Zk0uHCuQV1VwE9Bi79/xbH2qIJ3XIwXJ9X2yrLxiz2Jc Fmcus57pAE0ICAkdF7AIMWujWXCafbLO/9zMqelbJDL4SxfvviG1aHfgEY4ZM5lj/GWxSIHbD2W 8g= X-Google-Smtp-Source: AGHT+IFmWQXNK1wv9MJYHyLPbTQxbcB6DPrsAA4CF1+BS18uTfC/1R7KEvt0pZ4fv6hdU4QEgS7g0g== X-Received: by 2002:a05:600c:4746:b0:477:9fa0:7495 with SMTP id 5b1f17b1804b1-47d18be144fmr236909205e9.14.1766788266604; Fri, 26 Dec 2025 14:31:06 -0800 (PST) Received: from ivan-laptop.. (cpc92320-cmbg19-2-0-cust3144.5-4.cable.virginm.net. [82.13.76.73]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47be3a2b419sm190017475e9.1.2025.12.26.14.31.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Dec 2025 14:31:06 -0800 (PST) From: Ivan Orlov To: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org Cc: Ivan Orlov , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, pooja.katiyar@intel.com Subject: [PATCH] usb: ucsi: Fix null pointer dereference in ucsi_sync_control_common Date: Fri, 26 Dec 2025 22:30:53 +0000 Message-ID: <20251226223054.5565-1-ivan.orlov0322@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" Before 'ucsi_acknowledge' calls 'ucsi_sync_control_common', it sets 'message_in_size' to 0. However, if 'ucsi_register_device_pdos' was called after 'message_in_size' was set to 0, but before if (!ret && ucsi->message_in_size > 0 && *cci & ...) condition is evaluated, 'ucsi_sync_control_common' ends up dereferencing 'cci' which points to NULL. This is precisely what I'm observing on my Framework 16 laptop on the latest mainline kernel build. I don't see any synchronization primitives used to protect 'ucsi', so I presume just checking that 'cci' is not null here should fix the problem. It seems like prior to commit 3e082978c331 ("usb: typec: ucsi: Upd= ate UCSI structure to have message in and message out fields"), 'data' argument was checked in this condition, and it was always set to NULL from 'ucsi_acknowledge'. Thus, this problem did not exist. Fixes: 3e082978c331 ("usb: typec: ucsi: Update UCSI structure to have messa= ge in and message out fields") Signed-off-by: Ivan Orlov --- drivers/usb/typec/ucsi/ucsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 9b3df776137a..7d1f2a702d90 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -98,7 +98,7 @@ int ucsi_sync_control_common(struct ucsi *ucsi, u64 comma= nd, u32 *cci) ret =3D ucsi->ops->read_cci(ucsi, cci); =20 if (!ret && ucsi->message_in_size > 0 && - (*cci & UCSI_CCI_COMMAND_COMPLETE)) + cci && (*cci & UCSI_CCI_COMMAND_COMPLETE)) ret =3D ucsi->ops->read_message_in(ucsi, ucsi->message_in, ucsi->message_in_size); =20 --=20 2.43.0