From nobody Mon Feb 9 07:32:45 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 3B5602E5B3D for ; Thu, 22 Jan 2026 17:00:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769101253; cv=none; b=bGvkBPQTR/UJLAYCR1xVkOWuzCRkJ2M8p0RkS5oF8t3NZ9Z3bpD4rZeJhKOx0VKYd+SQSalFMP8NsHb4NbcH1BF/qhJw+22zS9nAs7bCdyll8EIjyKKhah0VyxW5qZNVOTGynz+VP8imQvyYCRGpJbhfWHzXwfmKxsYlHiUt9CU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769101253; c=relaxed/simple; bh=SYQnDRy3gXye1n8xw6IAVS14uNbovqYrq5pQMsKusI4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=FqHT5Zf3JztjdoRxIjw1RSDMutW40IE5K/ubQZprc4rAzerVgJ5/p8gdDtV5hgoXxI9utMmus7cDycOHk0vnCHxF6xjSUhm93m7voTpdakV/cwoXRw9A8GHsl/ndB9FpaCGwhLF0p/ir9Ofp2i4YuREsGK4CWMWDlVC7n++9IIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=eh+9t+jy; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=fxAh6VRn; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="eh+9t+jy"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="fxAh6VRn" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 60MDYnX33902374 for ; Thu, 22 Jan 2026 17:00:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=qcppdkim1; bh=2N6/IDHinoRDWXKmcT4CHhXv5X0fnjd64DC /fRTaml0=; b=eh+9t+jyoIXr+ztOK1/m8ShMiJZ2Ye62mt5D5BDMoYIjCdWn6RW t39bPS5tF+AlTr6YBRcbNRQudKMBA24Qix5gh1sJmPrOz8Q9RDDUiOUEfSHNc5Dk tlkjb6pKkvOsAV6v57rqm//ByBMSLiDatdKPIUf4N9okVVoP6RKvg2ZQihSgrTm9 ewOe6TdswbZFNp1bFpjLSc7zg+9vFdisAC1huU+BYiEgSOYLXW1HDB+eL3VnQSKn VCmRWN1K8wN7bxUWcypBTDMoDa/Tk23U6Jood5g4mGwVNAe5Dv3CcYXNQKialxzS K7h9zlb9aTS7umYQpzuau9iPDfHXlyck0RA== Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4bu4khku2h-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 22 Jan 2026 17:00:40 +0000 (GMT) Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-8ba026720eeso362598485a.1 for ; Thu, 22 Jan 2026 09:00:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1769101239; x=1769706039; 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=2N6/IDHinoRDWXKmcT4CHhXv5X0fnjd64DC/fRTaml0=; b=fxAh6VRnfySKY6jszSJGDi4MkXh1kCFrEIqhABFtAVHTuDDoswWXSCFiBvU8UHkwX5 o69P4x3D/oV89bxyQcYPTQRIZqm2hz9mnm/Y0v9xYXMzXfQIyj/FYBdncxsirMTqTdsp 22YmUOWgYF3af9o+49BuvUvQS3Pc9ySAIK68ZeYGLIlNhFXIej0/gJgL003vPqee8Eh9 sH9XVDQNpj3Ahr7UkukklcQ8bvke3sLazfyjTWQ11n0Br0QOS3uTPphHI6vZRacgylgB IL7BPTAX4h2rTGGQJ09CuBfZ7WqKVppNr86frKp0DKWGszaVz80i0t8GjbRaf1TDQTL9 0scg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769101239; x=1769706039; 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=2N6/IDHinoRDWXKmcT4CHhXv5X0fnjd64DC/fRTaml0=; b=ceThDQioUSWyye+Wa80/433lxVOq6IziP9JnOweIDoNarkOUBxYTdk+W59e9o2u5Is sZvOvSAio6x6PRuXh/ycuMO1GMC9jkC3O0meTf11OkaRy4ocsMZZg79YzLENMgsNHzQV NefEDI7uv48OEoRrYZDeluHTL/Rnh3h7K0ePOulMzYNzUwqdar+7YOab4UyZF5kSVu8P iwN5Oi9uhUf6c8nwC8CpAcY4Y6VdGyjQF9G5nKrPLFtDHutTFcRrqVaauOzB6aEHP5Mc ocKSk4UUKhxBOgyMtU+xfziq/YliVG4n3OWy/g3/CqZcbz3U0SEbdflsM8vxcOttV99s ztlw== X-Forwarded-Encrypted: i=1; AJvYcCX/o6V+ksSX4gWvTbmP7knMMmyWnnrmUA69V/PkKdufW+5ldmzAODoEKGK3eTVn2owiNDT8A/Cr17W7pIA=@vger.kernel.org X-Gm-Message-State: AOJu0YxamuBaWZa0GsNzrQNC75jMEglpLlzzQftbStsdsFiP9jt5Ljyo h0sssPzq2C820dzUg0gcVSPmTbEk3aIUUUAQ8FRIusbAPfdJWy/NUaKgz34f2TL87kzWvNqQ5gd SAGJLY4Ai6hPBJgpVWEaOSti+0fL7thWZHBQRH7Wvb9Y5xEPfN81OqsmyVX70M0ncPtg= X-Gm-Gg: AZuq6aI1iT6kVbTaY7f180nW+fISxa2Jxn9rIqAJCVIHlmt/9vkXz+7Fv/7aZ8rpTIA DKm9fPBexajVwxZes4nosMyjBQo1og8LmcV6jGSvGR/fS/OeX5RW4C2FDSz13LR6Y5Amd9NQ/CB Tvm0Rps2uFWDLeyCei31fw6Uicd/aDK50+EP/XgMOffkxj5OTWGKpKI15HxZ/ubjuY4lo+iFlCI L30Ima0at1AHVIvCd75o54Kgvsl5mT94mFUNe3ERFFpKFxksJlZBz+SMDA+3aPqzhr3+E4IaX42 sLHq3saBgJ31JLHtQWXGrUOIzQPR0mqTakV/Pv4VpDLzmVa/zBENrX+nr5rY4KkLQ52+RIoxkZD ACfXu8PRujWohk6rg4urXXuCL4g== X-Received: by 2002:a05:620a:454d:b0:8b2:6b9e:5396 with SMTP id af79cd13be357-8c6e2e4c8abmr8930885a.83.1769101238557; Thu, 22 Jan 2026 09:00:38 -0800 (PST) X-Received: by 2002:a05:620a:454d:b0:8b2:6b9e:5396 with SMTP id af79cd13be357-8c6e2e4c8abmr8916285a.83.1769101237537; Thu, 22 Jan 2026 09:00:37 -0800 (PST) Received: from quoll ([178.197.218.229]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4804d26a91fsm578165e9.2.2026.01.22.09.00.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jan 2026 09:00:36 -0800 (PST) From: Krzysztof Kozlowski To: Greg Kroah-Hartman , Jiri Slaby , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Krzysztof Kozlowski , stable@vger.kernel.org Subject: [PATCH] serial: Fix not set tty->port race condition Date: Thu, 22 Jan 2026 18:00:32 +0100 Message-ID: <20260122170031.433724-2-krzysztof.kozlowski@oss.qualcomm.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3536; i=krzysztof.kozlowski@oss.qualcomm.com; h=from:subject; bh=SYQnDRy3gXye1n8xw6IAVS14uNbovqYrq5pQMsKusI4=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBpclev9cxxgZkXsMxsURilU3jXG5Z15qh8tFH8r BurBi4FwJeJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCaXJXrwAKCRDBN2bmhouD 15YVEACPEgsrQyYmGt5uibl1LL0ijwt7jnSAoHiI64wWhYYwcYSLWR8wROlbnqnTx9GXX0/rJw6 ATM9QQ2xIMwO1y5r38utI/+TwE8VDP+me3XbOUBoc2JEmOxtfXYLpEGM5q8smw7wz+jHNPkR+fa Vis5yZRwvcHvNcYMCFIl2ENlfGpVKxg7hKSQb4x2sZmtNCNnMnmQk2KAB3zlrNsB0y1znrYjmL9 YKVxtZ60eoQhbR2IMvg5RqnNX5u+bcVUMaqpeGqDmUAiLvN8oRA87CIzTbiS9npcq/5UyIiX1cd GXgbSgCuyCkr22p9Bn045Sk8VUW+PzyHMHKHynHqzkJziDC5NRZot3fJ7jpSeOAzyZ0fhqi+taI hrClK7cHMtuNM5hm/+sKTgx2ABAqvgPhL2fLwhDBApII4FSwghzxjC/523tBTbyivzwFHUXru2w sHCy96cCBZfA8POcMHxn4RATatunEo6AsGK7Ur5HwSdee+1OoQVf8EBL6GXQenpztWMUj7lcfP1 aoKIUPPdJdijFJmEDvhVeYokq+Eqp7+B3aueKM/q94xsutLkZyb/wkVvLxA2BSQnceX9JIK2BZW JYv69gkXFzrqMswNsLOdZY8LpaKhLvvZsab9WqnY4Bp3iGIXRDmhKA9yLUE/4smw7ww7W0fmknb CgRu0hjNCxAnfGA== X-Developer-Key: i=krzysztof.kozlowski@oss.qualcomm.com; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTIyMDEyOCBTYWx0ZWRfX4eomBl87Vzw7 z8YsQd+52rBSn2Di0tokLpeJqqL43TclBGEmPrdT914Qf+gfOcVeVPlL0ZT2D0UKV5bhT1Eh8My 8YD/nW9NBHtv4mC5FDrVoT19/J5YNmZwopjsv4SixzH5angL6fUoj1D7E4T+mS8HcTP9/CbpxHO p78Q05k34fO7R7RySI+w/OuF3O961J+KB4PZLp6cOY1S+i7IZw5x9KN5TFxjlsHhtSZ62KyOBlt JXY4UUShdIgVmNApbH5MzrEqRp5WTgbtKsvzjxEFvx/assCt9tVCk+7adyjQ0b6MoEGYHVZLeqL RG7sLH/WLGGupiE/j7ROMN2Cp3jfEsL/CuZoFM7UNd15tE83p0zgEio3FqX273byqd1vW0g/l5V KKPTbNDoJvqTWL7/ujgL2UueYUUf1xCznai9v5+kGzXeWDM7Nf50YtIxWzmC1EzMu0hicR82Nf/ PhnqC6xzBebr226hqBw== X-Proofpoint-ORIG-GUID: BMLVWDGWderQXwkbrtST80KsPjUVKQdJ X-Authority-Analysis: v=2.4 cv=UOjQ3Sfy c=1 sm=1 tr=0 ts=697257b8 cx=c_pps a=qKBjSQ1v91RyAK45QCPf5w==:117 a=Eb9f15NH/cHKzfGOmZSO4Q==:17 a=vUbySO9Y5rIA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=10lJyrFIdA-fwsh8KigA:9 a=NFOGd7dJGGMPyQGDc5-O:22 X-Proofpoint-GUID: BMLVWDGWderQXwkbrtST80KsPjUVKQdJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.20,FMLib:17.12.100.49 definitions=2026-01-22_03,2026-01-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 suspectscore=0 bulkscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 priorityscore=1501 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2601220128 Content-Type: text/plain; charset="utf-8" Revert commit bfc467db60b7 ("serial: remove redundant tty_port_link_device()") because the tty_port_link_device() is not redundant: the tty->port has to be confured before we call uart_configure_port(), otherwise user-space can open console without TTY linked to the driver. This tty_port_link_device() was added explicitly to avoid this exact issue in commit fb2b90014d78 ("tty: link tty and port before configuring it as console"), so offending commit basically reverted the fix saying it is redundant without addressing the actual race condition presented there. Reproducible always as tty->port warning on Qualcomm SoC with most of devices disabled, so with very fast boot, and one serial device being the console: printk: legacy console [ttyMSM0] enabled printk: legacy console [ttyMSM0] enabled printk: legacy bootconsole [qcom_geni0] disabled printk: legacy bootconsole [qcom_geni0] disabled ------------[ cut here ]------------ tty_init_dev: ttyMSM driver does not set tty->port. This would crash the = kernel. Fix the driver! WARNING: drivers/tty/tty_io.c:1414 at tty_init_dev.part.0+0x228/0x25c, CP= U#2: systemd/1 Modules linked in: socinfo tcsrcc_eliza gcc_eliza sm3_ce fuse ipv6 CPU: 2 UID: 0 PID: 1 Comm: systemd Tainted: G S 6.19.0-r= c4-next-20260108-00024-g2202f4d30aa8 #73 PREEMPT Tainted: [S]=3DCPU_OUT_OF_SPEC Hardware name: Qualcomm Technologies, Inc. Eliza (DT) ... tty_init_dev.part.0 (drivers/tty/tty_io.c:1414 (discriminator 11)) (P) tty_open (arch/arm64/include/asm/atomic_ll_sc.h:95 (discriminator 3) driv= ers/tty/tty_io.c:2073 (discriminator 3) drivers/tty/tty_io.c:2120 (discrimi= nator 3)) chrdev_open (fs/char_dev.c:411) do_dentry_open (fs/open.c:962) vfs_open (fs/open.c:1094) do_open (fs/namei.c:4634) path_openat (fs/namei.c:4793) do_filp_open (fs/namei.c:4820) do_sys_openat2 (fs/open.c:1391 (discriminator 3)) ... Starting Network Name Resolution... Apparently the flow with this small Yocto-based ramdisk user-space is: driver (qcom_geni_serial.c): user-space: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D qcom_geni_serial_probe() uart_add_one_port() serial_core_register_port() serial_core_add_one_port() uart_configure_port() register_console() | | open console | ... | tty_init_dev() | driver->ports[idx] is NULL | tty_port_register_device_attr_serdev() tty_port_link_device() <- set driver->ports[idx] Fixes: bfc467db60b7 ("serial: remove redundant tty_port_link_device()") Cc: Signed-off-by: Krzysztof Kozlowski --- drivers/tty/serial/serial_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_c= ore.c index 0534b2eb1682..116f33f0643f 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3077,6 +3077,7 @@ static int serial_core_add_one_port(struct uart_drive= r *drv, struct uart_port *u if (uport->cons && uport->dev) of_console_check(uport->dev->of_node, uport->cons->name, uport->line); =20 + tty_port_link_device(port, drv->tty_driver, uport->line); uart_configure_port(drv, state, uport); =20 port->console =3D uart_console(uport); --=20 2.51.0