Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp2038905lqp; Tue, 16 Apr 2024 05:58:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVNiPLpoBsA327EKAOrOq1oQMJUYIimwxwRGqd5I42OF1jbIcpobx+GRsqWR8Nktm5Nk/VjZf5hVNMToVKWwAS2XkwJr7ulb/ff1UEc1Q== X-Google-Smtp-Source: AGHT+IEQ/+pVNZqokOGsF2umOz0j5HSsjfLuZUoDqUaDzZaHeDjyi+uffU2M0xKxow5XkNWOpaB8 X-Received: by 2002:a05:620a:904:b0:78e:de30:93f5 with SMTP id v4-20020a05620a090400b0078ede3093f5mr7373807qkv.31.1713272309802; Tue, 16 Apr 2024 05:58:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713272309; cv=pass; d=google.com; s=arc-20160816; b=sspOoHcuci3xMYenLrAfsHhV6X6T0Pb06vEjnVV61n9ArKyobBCFp5kjCqTgu5VMA0 iw6wtEQXxDwHehXm/EK62nnr7QHtCxuOZ/LP6y2BrtkbLxX1bKayEikcA7bGq343BMTJ 9HW3qK3EKZtjL59/TTeQb6A4wBL29+tlx6zDvyISNNOtyTaRDWkUxGYynqnRX5nPmirk DFlfzqGPIwZJSZE11dcUNu07FiYEiTYwIWe71Yx5qkBdPxClE/Betehv0ihZZaNZk/kF pyAt5Rl0hO932BWefoALqTtTq8xvr0Ud4rczpCuNuh5pq2a05Uqbrvwb9sTNz7Cf5VbY RDEA== 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=kAv0oBFkgwwU3Vt2YCqpLc+ik9GcQOdElLHJtyXfBOo=; fh=UAlP0tWVS1VUiTuieYB0+FkAEm6iJ8ONagIjk60unwM=; b=wZykgHJRrN5B84j6Ohe0Uo16f2hfStTXVrdb557HX70ICFmh6ZyVN4bdMDvGxz3xFB UPbKtWGtYPZhmbRyxBlipv6zj3eTyFG7Glr/jk2ip+dcYvcuocNt33iklzhXRgJeJro2 COSIY6ZGucnv+eqHFqKZI2wHQHPjV/d+e7ob2eSkSY9pigE5anORxB5GIDarh7GwR/l5 jKPSzf8hO3AC5McjnrDNCdxr8YUrJql5pvWqWqw8WvrNwVxewN6iEuHyhYNE4EifS/uR YizD6cmOZovJ+A4AaEFPMjJ1ZaTk8pshwNineih711F/8rvRMUWINTuc4pVeiGOm0wu8 SxuA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@finest.io header.s=s1-ionos header.b=EWYhDEmy; arc=pass (i=1 spf=pass spfdomain=finest.io dkim=pass dkdomain=finest.io); spf=pass (google.com: domain of linux-kernel+bounces-146839-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146839-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u26-20020a05620a085a00b0078ee7907da6si4648269qku.342.2024.04.16.05.58.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 05:58:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146839-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@finest.io header.s=s1-ionos header.b=EWYhDEmy; arc=pass (i=1 spf=pass spfdomain=finest.io dkim=pass dkdomain=finest.io); spf=pass (google.com: domain of linux-kernel+bounces-146839-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146839-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 73FD31C21888 for ; Tue, 16 Apr 2024 12:58:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1EDB312F365; Tue, 16 Apr 2024 12:57:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=finest.io header.i=parker@finest.io header.b="EWYhDEmy" Received: from mout.perfora.net (mout.perfora.net [74.208.4.194]) (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 B301E12C7FA; Tue, 16 Apr 2024 12:56:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.208.4.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713272219; cv=none; b=b9zB4TPO/HVpNXgIKI9rUU7IYSewF/Co/I7zX0QxnS8p7U1UoWXf83IqDDYogin73ghfIhGo0la9hWOHHTkfpcnIayghaZA+TdrcIFdliNby8VCBm5OOoWFRGDGHoj9cKrryOJE3dwTvx7luOYp+ZWXGkQk2P+molsYLqMmxJeI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713272219; c=relaxed/simple; bh=BeHbDLxRX4WOrHYa4ThT+3HJ8zBUg6fW2R74rAnsV38=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tVR5wdFdSMic4xKez7LMslkdYgJ1APH1bqZwS81blo7L/tdMeo8mMzRThgkaCE+R51O2QpmpGqEsCAazmCAn3AaXvvDJUy375dmjNwLnlHNb1EoASM48qvGoYrv2xldbAaszDc9FeZw2gw+mAMDj80XivsqrJ+NGH90FOGYmxtc= 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=EWYhDEmy; arc=none smtp.client-ip=74.208.4.194 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=1713272198; x=1713876998; i=parker@finest.io; bh=kAv0oBFkgwwU3Vt2YCqpLc+ik9GcQOdElLHJtyXfBOo=; 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=EWYhDEmySObpxDKJlYLm19HJhmWDuGRRG7zLtQ+qS8WdDpBpzpSiAxEk2FogTDKq JDTZD05z/D04Hnt/UvQ4/KvKZgkJfSTQKbPUfdDnznn1cf5qcotxk87hRZ6+oa0mK zF1hxawKorfmyFSRu/N0HomgvXvOcT62xSeMSTOkb/+kY+y0KmlUiy1GD5edooMJI 0ba2PcJSk26I35eMprZ+kDNUXAeE5ZcM3YrnsuQqLfuuSruhYrK0Y59AYvLSTaGCo EiKy8p/uZQk5E11ukcjaPSI7ZUsRUthZNMBycLfsA/bYKw9JOS6nmmP2pCGynUwmh RgaFX/mrfD6yEeRWSw== 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 0M5uwh-1shFHT0wnJ-017VYa; Tue, 16 Apr 2024 14:56:38 +0200 From: Parker Newman To: Greg Kroah-Hartman , Jiri Slaby , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Parker Newman Subject: [PATCH v3 8/8] serial: exar: fix: fix crash during shutdown if setup fails Date: Tue, 16 Apr 2024 08:55:35 -0400 Message-ID: <1a21fffe403d7181e0404db1ed92140c306f97b7.1713270624.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:Aix2Gfbz3WAlz2Z+lR82+NyyweP0ySGfxPJud5y3h/eaUD+TfCK tNX9oGSruoLdOu9OVjQ9Uo+0rMlWuAnj6QsQuf3NDwyJeJenh9G0YNuqjDrvxGC9To3Prd5 jnZUmHyyBgT1l7zjRXaSm1ujrg3CmsH+J0VneP9UY/0irnodH4Aa//OhmPjPqbOQZeA8qvd qvFGMX5q3L8Sz2gc/pDIg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:R9jOjENT1WY=;ejdCrwwafJxLraDIM3YWdGe5Gf8 TGgftdLfb0YEcoJYUk0MjEIP5PuK3s748EFwOTKaLY+Pq67vKwXlBwwF6Qr2vRrcq7L3SIdyI ysVumb/Co+kA88d4EnuG+4x/6O0tWghnHZXILOYGY+grItIiuXDDBue+YGPsojqQe/vQFCu5j AnM5ofSPS1mRszGgXFvhgtEyU56eKQwL/kQPAumflvQARki2PgJ4EtskR9xbqSQuv0Lv64oH1 4BHQXvS8+9kES+adbpXhgmg8qJx0KNTUNBRlc2QE3qzfSZqa67dmyl9sG1+75pkPjusK5YWqO dbNGBATZ2m8olWBCF3w/91oDCqfQZ5sASj4VQ+iFfbEMhI9UE5bX+ve05LagaY3wxSKdQD57K 85LMfFDKXgdBsYuNP3iCqh0/eKX7k8Ut8ntFm/p+/9WiPYFFbN41dn+hjOFfmhhCK+KAaBpLC EnvcA5GERyQum/2sHmHkh2gkjT+K4S7xvi9KNWBmRztfGF4+MFs929LvBWT/MZ1c29emR83Ao RZSvao8gY2jnbrYQvmBdmHxzFDr0qHlmjqS9mOZTXXjDpb1+S+bUJdhSFTpIzFsWz0Ak0iQdR Csqskd5/909oaQ3kbEe042qJU62/boQ1w7xDTaMMdUARd0u1l2ktaUbvJtXIjCHJLGpYZC/4Q OV4ZW0lBaNndXjHuKj0L55EB0NoyqPeg+rN9YX4gufMj9w9ko44hKulEjeQX/xzkmNgQVOt0V eiF47/CMa5tfT5XvMX9PeNVTtTPxP1P+frurlBoSXwIT7gPCDQTyvg= 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 and in 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 501b9f3e9c89..f5a395ed69d1 100644 =2D-- a/drivers/tty/serial/8250/8250_exar.c +++ b/drivers/tty/serial/8250/8250_exar.c @@ -1671,7 +1671,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