From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6C820189BB5; Thu, 15 Aug 2024 13:47:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723729651; cv=none; b=AU4BeaAqyMk2llhI/EKMXZcrEO01q8Ovb9R8n6huSg9g9tFtSsfjvqHJ8Mr8kd2Xy9XbNiRaoDBT5sJqPEJVK+SmSIRUxjyAw6ZnRqEC++Usw/aWPakO8fUDC7uFMmMO1hbv0WIa6IagRKjnx1NQEZwyYfWcdNQCOb01ug2NADw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723729651; c=relaxed/simple; bh=Mf6Whb9AGMEzz51IeYZe5rFrQHOZfLRPrVzmdcMluAM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l3zbC1ZluinMWvAlAI84zPUNdtDKCX1g3i9B7l4zOQ7rAxW1vvBJDYozYrruZntBbACRcSr+NRbJSaBeKqpygS+w0b7HUi9lBNUO7xmezqX4VlAL0P9ZXHK7IGm7veyEmc1ltBT0Y4hlZY4zC4GIZNhVedWUYr9psWhRXQ7/0hM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=mCV5ggDL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="mCV5ggDL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E012FC32786; Thu, 15 Aug 2024 13:47:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1723729651; bh=Mf6Whb9AGMEzz51IeYZe5rFrQHOZfLRPrVzmdcMluAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mCV5ggDLRqKCdytnxegvC5LLK6SYvtv7/peEMvnC+i+4Sq6QCADMq+DEd2s2DltJI 3AWH2ABB28CzjNsJZb1vbkRPiSHYUG6PR1D+6z66HHrdpjnIXxw61OZFwCJ7bW5XL1 1fgqJloW23008MyYqe4wtKqesfPvQebZnHVs+ImQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Sasha Levin Subject: [PATCH 5.15 134/484] PCI: endpoint: Clean up error handling in vpci_scan_bus() Date: Thu, 15 Aug 2024 15:19:52 +0200 Message-ID: <20240815131946.581943257@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240815131941.255804951@linuxfoundation.org> References: <20240815131941.255804951@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter [ Upstream commit 8e0f5a96c534f781e8c57ca30459448b3bfe5429 ] Smatch complains about inconsistent NULL checking in vpci_scan_bus(): drivers/pci/endpoint/functions/pci-epf-vntb.c:1024 vpci_scan_bus() error: we previously assumed 'vpci_bus' could be null (see line 1021) Instead of printing an error message and then crashing we should return an error code and clean up. Also the NULL check is reversed so it prints an error for success instead of failure. Fixes: e35f56bb0330 ("PCI: endpoint: Support NTB transfer between RC and EP") Link: https://lore.kernel.org/linux-pci/68e0f6a4-fd57-45d0-945b-0876f2c8cb86@moroto.mountain Signed-off-by: Dan Carpenter Signed-off-by: Krzysztof Wilczyński Reviewed-by: Ilpo Järvinen Signed-off-by: Sasha Levin --- drivers/pci/endpoint/functions/pci-epf-vntb.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c index d4cd4bd4a0881..fb926b300c951 100644 --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c @@ -993,8 +993,10 @@ static int vpci_scan_bus(void *sysdata) struct epf_ntb *ndev = sysdata; vpci_bus = pci_scan_bus(ndev->vbus_number, &vpci_ops, sysdata); - if (vpci_bus) - pr_err("create pci bus\n"); + if (!vpci_bus) { + pr_err("create pci bus failed\n"); + return -EINVAL; + } pci_bus_add_devices(vpci_bus); @@ -1313,10 +1315,14 @@ static int epf_ntb_bind(struct pci_epf *epf) goto err_bar_alloc; } - vpci_scan_bus(ntb); + ret = vpci_scan_bus(ntb); + if (ret) + goto err_unregister; return 0; +err_unregister: + pci_unregister_driver(&vntb_pci_driver); err_bar_alloc: epf_ntb_config_spad_bar_free(ntb); -- 2.43.0