From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 9E1202C3245 for ; Sun, 19 Jul 2026 16:08:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784477307; cv=none; b=hc3+LjT9ckgdnA6Vmqk/JNsFIS94bKZCOHi+YIKXFONJ5xd4kW6a+R3hIVaz8vfRXOr6Ox9hksC3/nNguSPgHpfZMSXL3QQhtoct2ePzG7O7KRuiRlqHUtvbrBfQNTadoCX7PLBTIBYSqwu4SDVs4D0at4Uppb5pK8RcsMr8GNo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784477307; c=relaxed/simple; bh=mziCgHHnU/wl0EtRGbMHh07Co7AfovVZx/sOCmyHV8w=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=eF5y7l9x5Uc35lhBiTinrVqx1NyqT7WbLunYDF7bdaxOX1Sshk8RN/FQuX7SU8Cxuq1DY3N42eOn3kRYbfs44ZhOdCNaCLROStCwR2mpsForTax9tyuUCxDUV/0VbfRMz+0+VgLos7R9xFHqN40pveoiOY2aSvKaJOYHxrQN3aU= 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=Ays9ZCii; arc=none smtp.client-ip=209.85.128.52 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="Ays9ZCii" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4955de8797cso1093315e9.3 for ; Sun, 19 Jul 2026 09:08:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784477304; x=1785082104; 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:content-type; bh=IN4Hj7JaG8b++jqQRlTsZ8ObY56xxPIUhNKD/QRpNuQ=; b=Ays9ZCiiaOadqGb4deolK2coGSmVRidt1S3VK0iTzYDj5ngHzqzRIDrhJZxiuiCW28 HTOKUjlhQ/rOm2z8JHP8EF6VLCbuPDO7ZjTjCTF3M7ee7l0SfCAWHu9LU18wZMV2g/Tw LvDeCxWVHUxsZLVMRhSIrz7LHW9vyoWkLSpfa28oTsUdioETolXifBA6Uo8Q0cpmhiVE PDhW0ya9/YsKfGI9Ba8X4DFKXoeJ1uxn8fanTNgQsRrZ78TEjfxLquYrObCgnQ3ka1RZ yV3Tpd40vGulpCLV/fO2fDlAIsqgBjmkMd0Rr4bqnNwyHCbs5iXBPUCDkP22SE7n9nPp iwqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784477304; x=1785082104; 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:content-type; bh=IN4Hj7JaG8b++jqQRlTsZ8ObY56xxPIUhNKD/QRpNuQ=; b=kcyONOKQknc/SnDDEbciUikL674ZXTDqXzvnD4Gkgt1QsrpfPc8Sv5xWRw1QAyuK2W mxv4Gx/+sXZBF2DLDGr06jVRXxV7jVD3s1mrjoaZ8OPp6e72PXu7qjzH+a/tL+ohJqLH 0TEr8VHMhF/8rmswe398Us8lvPT24j4wJqn/3PsQz8fEb5z+wIkvPcQ26km9sY/GfqL1 /YG0iRJ2x/OF4KS6lfNrEIB0mmJ+n2j0M6apFJ9VNkeUP1/x1NnXmiiH7/BDGy3FAm+r Js17s/dIj7h02HB1Op1GEKdRsY9Lj21W18GrlRssBTJU+TkcfdNmRBtSQom/XllUnpOU j1YA== X-Forwarded-Encrypted: i=1; AHgh+Ro9JrWVccD2e0onm7uI+J38y3quL6m1s58EF5SmTOOvLK7G3/2pMxz30XWyUDBy9drvW/xXzxqXakm85UY=@vger.kernel.org X-Gm-Message-State: AOJu0YwFXhsIlk17dUhhp/3P3ZROvKkGEN4DW4+947f8o6+XXLOX8V9B 4i1p4clBeqZbUMPqA0Rr4BwIDGKdjb+U1nsLBjUDAkaX7IorbFqjG/rg X-Gm-Gg: AfdE7cky27WDvJgHZhII6RFVki/sekut1CwwqFKo21MA9hi5mN14cVEYjyQ7HHVurtw s6djgm2SMw+5NaEnzwK3aDXoXZilSH38uCXCvYuB3CVOmRm0Sku7DY5SzPPSE411q6MopeShFPd e+sfKFrtN8GVBWicsnkgo6YEMVEPklaUQBqSqu3eKYoKijxh9ThhdEWLnEvsRA24tOb6Ll7U2be PWMCgv27lEn57gSH5aCpbJUFU4SWbZ1NcpRPDNkkGehB0trxvGyFiTo0PVoKevADvhRsPhLyk9P CyrZ3L+19waXPaU4yiHEpW0zaRHYi+rxKyV2BPZ58Oockt4DG3yqhrE5KkEVtieUW+OZ51yJEHz BUORrrc4NCEeKRvUU30/C9qKP4DmFZiQ/0h7AT8Z2D08v1rkaOmbJm5HI7sV7zEgWe9qWz2Zeza K2g/yYCUohE4/i73s0c8PfPjJR17Z4SqEsE/VRseG2oISyJFpVg41Xo0gs1VBvd7YIPBaL+4pk1 weiRF7/gD0/Fqu9CgMJC1jlzmJWDProExuc34TZwKGg6zFdgnXag90IY5ZSRJeQmwsJpH/Av/Bh Sk4chwaB2MBVlAsj2+zn X-Received: by 2002:a05:600c:c097:b0:495:5a91:8027 with SMTP id 5b1f17b1804b1-4955a9182a8mr26079975e9.5.1784477303312; Sun, 19 Jul 2026 09:08:23 -0700 (PDT) Received: from localhost.localdomain (dynamic-2a02-3100-aeaf-bd01-78a0-2a2d-507f-c97c.310.pool.telefonica.de. [2a02:3100:aeaf:bd01:78a0:2a2d:507f:c97c]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4954a2edbe4sm223826745e9.12.2026.07.19.09.08.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 19 Jul 2026 09:08:22 -0700 (PDT) From: Karl Mehltretter To: Greg Kroah-Hartman , Jiri Slaby Cc: Karl Mehltretter , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH 0/4] serial: fix console lifetime bugs on failed bind and removal Date: Sun, 19 Jul 2026 18:08:08 +0200 Message-Id: <20260719160812.35407-1-kmehltretter@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This series fixes serial/tty lifetime bugs found while injecting allocation failures into the UART bind path. The failures were reproduced on QEMU's raspi1ap (amba-pl011) and mcimx6ul-evk (imx) machines. The first three patches fix shared serial/tty error paths: move fallible port allocations before console registration, clear state after failed uart_driver registration, and track whether a live cdev is registered. The final patch fixes the lifetime of the i.MX driver's private console-port table on probe failure and removal. The i.MX probe-failure fix spans patches 1 and 4. Serial core must not return an error while leaving the console registered, and the i.MX driver must clear its table entry before the failed probe frees the port. With all four patches applied, fail-nth sweeps of the console UART bind path completed on both machines without a KASAN report or oops. Every failed bind left the console unregistered, and the i.MX unbind/rebind reproducer also ran cleanly. This follows up on the discussion here: https://lore.kernel.org/r/alyjOGyTd19Obemi@MacBook-Pro-von-Karl Karl Mehltretter (4): serial: core: do fallible allocations before the console can be registered serial: core: clear freed pointers on uart_register_driver() failure tty: don't oops in tty_unregister_device() when no cdev is registered serial: imx: clear imx_uart_ports[] entry on probe failure and removal drivers/tty/serial/imx.c | 4 ++++ drivers/tty/serial/serial_core.c | 33 ++++++++++++++++++------------- drivers/tty/tty_io.c | 6 ++++-- 3 files changed, 27 insertions(+), 16 deletions(-) -- 2.53.0