Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp49559lqn; Thu, 11 Apr 2024 13:27:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWzAhIubfNHmpW94Ce5hFk6Bi0/Bj+DUZadJtnazn/HeE8/5cSudrZj/L+H4B16NTxtbJQn7eZOUumufMIoK0t3eQo7bwwNg64K/zeiCg== X-Google-Smtp-Source: AGHT+IE7A1N0pPT2Nmw422vfGWVVisslPNVu96OmsMvu0KWIcPiLnccT4g/v9Ii3YHhH70DSLeRW X-Received: by 2002:a05:6870:9723:b0:22e:f717:c6a9 with SMTP id n35-20020a056870972300b0022ef717c6a9mr707979oaq.34.1712867247316; Thu, 11 Apr 2024 13:27:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712867247; cv=pass; d=google.com; s=arc-20160816; b=N0AOHuvStqfm26uBEX5SkeBFWWeWWBBR74nygFPsbN1P5es9vDDmpC+GH8TZV8TvxW RnloB16HDPxorUzCReUD+WHtfPfFSAxdsmiOrm/Y49K+LHWzQpT7HgO/+ESAK8BsWxSb fKVfAArbRbkWg0EgqHbhkteTdPMW3IQXY7BdUhPbPnt+OyqYQxjzTpvBkHX4oXbXnOJ0 cv2PSOmKHnJhpoXi2fX2ZfIF2gVHJ0bQWqu6vBGYVTEphTrfF0Y+WW0tysMBzlUyTkF/ vhRBAwiaPEbRUehbDCspBsLfAeXa2AVy3aQ2dF17CojNcStzm4CKf1p437lKTQN4c7lT rFPw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=vaELCzZnSbZPiv+n/DYJ9hiAKVejhtPPQdvjQgpLFGM=; fh=UAlP0tWVS1VUiTuieYB0+FkAEm6iJ8ONagIjk60unwM=; b=knEJRGyHQAb0UazNgGc/wStmgwkgcou6dfh8kfSW9khgC2helax7CJANkCrpz1Lr+r jmGAgg76LdzpTP0gBflkN6QTttw4iymxfxs5drWK531Fz8dd0enB6m2eUPvp64tZEcNu kzaivll4NsORXLMl7iqr7v5/nbKa4WId2dJcVCwthhgbRqj3D6eIniDMv6pQCL0WOvRa 1uvDsGPSh3Q6Bi3Tbc2nmX1iFFNARtu2i4fSyCJRS/f/bAUi80t087lwdbCN5KSTqlxi VzCcUNxPMQvdXGSJ8sQo3ByKfqWN0AuLzyhqPAWFkpwdEQDjlngbUDhTo/7mGUghWaCr myTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@finest.io header.s=s1-ionos header.b=ix8tw4bK; arc=pass (i=1 spf=pass spfdomain=finest.io dkim=pass dkdomain=finest.io); spf=pass (google.com: domain of linux-kernel+bounces-141574-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141574-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x20-20020ac85f14000000b004347d76f444si2192736qta.597.2024.04.11.13.27.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 13:27:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141574-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@finest.io header.s=s1-ionos header.b=ix8tw4bK; arc=pass (i=1 spf=pass spfdomain=finest.io dkim=pass dkdomain=finest.io); spf=pass (google.com: domain of linux-kernel+bounces-141574-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141574-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 93A761C23794 for ; Thu, 11 Apr 2024 20:27:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3288C3D982; Thu, 11 Apr 2024 20:26:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=finest.io header.i=parker@finest.io header.b="ix8tw4bK" Received: from mout.perfora.net (mout.perfora.net [74.208.4.196]) (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 F30DA18030; Thu, 11 Apr 2024 20:26:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.208.4.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712867167; cv=none; b=T/HENZC5bmKA+GU055elSgMUypfbVmFVYc0pgpbfW8rK6C6MJHSPohsVbbq5UPTN3++uM72IJr6QqYQJL+ErX2qoRA6F8XkcEc2+6BwfEN/eKUX5gSmGNFAN46XgLq8FaWJ/ey9WSFx0p6ca9HXwvDHGw6N47e0K3J8xMdUMKqY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712867167; c=relaxed/simple; bh=OyiwdrslugF9xn2I0IrJDXL7cDDj3UpTmiAZkhP4QoQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V9Eh0kDJPr5fewNFqic7Za3eGfoJbOyHL5S1AKfyEmerJH4B8CyK9LelIcZ7zCSXfEuZ2kVcjRkcAU8SZ23Rk+UrTfuxPs2vhY+vLpTX52fGFZ7SvoBiw5hvZaBOvxc+TkcnDcPZnnNGOmax60K6QLPHG0eCfvtPmmmJMzvOfEw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=finest.io; spf=pass smtp.mailfrom=finest.io; dkim=pass (2048-bit key) header.d=finest.io header.i=parker@finest.io header.b=ix8tw4bK; arc=none smtp.client-ip=74.208.4.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=finest.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=finest.io DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=finest.io; s=s1-ionos; t=1712867159; x=1713471959; i=parker@finest.io; bh=vaELCzZnSbZPiv+n/DYJ9hiAKVejhtPPQdvjQgpLFGM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=ix8tw4bKi/WKkO7/oGnNp19593x3C8aBKaf4+ueWgCm1jgBHZlc0Rx1cYDMx7zEO K0C+A3ydGzuhCpB4DoejnwLY6vzvfBiVXzLt7MTWq6uZfj2k8Xm7j4QTOXWUWx0WN zG2Mxy3A7gX0KI36QzSmHQFAK4essD6SERYwOAyHMZwT0PET1Srj7fvzwKFAgxnR2 pzTCZu4NPsAHpz1tsNLalG0q0UND6Ul/dOC3plgbn5Gc1T2cL5NE2VIlhIeGp5aoA f44XBiQJsF0NRQfOM2V2MlpsUurM/8kawdeXgSSSVzHvRBwwSu8VqBzPEwnM4xnC7 5mnzWar1BZqx8kMFtw== X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from finest.io ([98.159.241.229]) by mrelay.perfora.net (mreueus002 [74.208.5.2]) with ESMTPSA (Nemesis) id 0MXriD-1sIuhc0Yzf-00Mdkl; Thu, 11 Apr 2024 22:25:59 +0200 From: parker@finest.io To: Greg Kroah-Hartman , Jiri Slaby , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Parker Newman Subject: [PATCH v2 7/7] serial: exar: fix: fix crash during shutdown if setup fails Date: Thu, 11 Apr 2024 16:25:45 -0400 Message-ID: <9af149b983592a7b8763132c64ca269909b4b8d3.1712863999.git.pnewman@connecttech.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: 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 X-Provags-ID: V03:K1:s1qZqYeeCh/p55n0hx6/aal+F/Q4pAG+Wd3llXFjndMKaBsI6W7 Qhes136f0gHDTPSamEW9VgEwV9Vk5kGq06drYjuPtHmKimt3LZUTWWI7zQML2URCGJwZn86 07PD0QSb4ddP/TlJqqvQi//4ZMuXgfY5AujJSMzuX+JBv3zbNTtETBflaPr39v4FoxBfIyX tWJ9KBqy3yimxtK6dHmgQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:kyFkFkRSoq0=;eeDmdpPDU1OJ7YPEsz61CCfLQFe zwVOh3DvjJoO6wJkHveiEkrZg+D/CF/Df2JKSIeMZh3TOmADpzfSp+HpQxX2YqmIzL0/KUCM/ qewwFjewvrHNcVmDBrLL1kXKcb0WWkHNWoj5SN6foAFfN/WagtWS3743O/4u8XcAUsrCOQAjg Lhz5I9cIj6fPHi0i2Z/TICA9ifKDH4UHBM2Y+X2GsfkD4H4daY3346NAC6xkBqmeU4MtXnsXs 3LU/ORoCgBkgjVYnn5KaDbDToeN7j8UJ3D6QRJXRBIMyiH1WUvZWedTBTzLXARwyKCrPCYc/9 vIyT8XCPtyEKNc9qJqbx5Nw23WUbIE8RCaS2TC3dYH9h4o50O5JINfTiGro4Q0R3vb3bdA2nY 8d0BjrSWYaR1z0fn8vcAXHtDIkdPUGTEdZC/9zEuiOQ0z+o8qV67G4vf/bB53JwXtcWUC7Inq J+dZJ1fwmif0UJul3v1LkK8oTu1oFjYp91IbKfI/RIZQ7r6gihYeuH6wJ+n8y0FG3OZkUTARN 6mNaj8F6KO+YOVPyEPIlSU0Xuilwx5dznAcAEEuc0xwcxL8wUju3hwKS6AY7JDDq3/KOg2d8Y sObNF4plZQjOIV3lvLRaZ9bR3ZmjpUP1HOrCi4Axwiv25qtGxaVh9um7f+mc7iuZxfN04kaHo esJYhcpI4fVxDaTLIvJbvjsiJdQ/6xZjrEqP+14ckltGm8Huuq420VEoSs6B1xQgx6m0q4xSa hX6Mud+2fBLwxtVQkmJZDKbdm8IHXifHdwtYOcR9uz8rEfsu0QR6dU= From: Parker Newman If a port fails to register with serial8250_register_8250_port the kernel can crash when shutting down or module removal. This is because "priv->line[i]" will be set to a negative error code andin the exar_pci_remove function serial8250_unregister_port is called without checking if the "priv->line[i]" value is valid. Signed-off-by: Parker Newman =2D-- drivers/tty/serial/8250/8250_exar.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250= /8250_exar.c index d8425113a9f1..1c6343ed76e9 100644 =2D-- a/drivers/tty/serial/8250/8250_exar.c +++ b/drivers/tty/serial/8250/8250_exar.c @@ -1675,7 +1675,8 @@ static void exar_pci_remove(struct pci_dev *pcidev) unsigned int i; for (i =3D 0; i < priv->nr; i++) - serial8250_unregister_port(priv->line[i]); + if (priv->line[i] >=3D 0) + serial8250_unregister_port(priv->line[i]); /* Ensure that every init quirk is properly torn down */ if (priv->board->exit) =2D- 2.43.2