From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 5D041407CDA; Tue, 21 Jul 2026 22:13:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784672007; cv=none; b=Rv85UEQSnz8bNaaaC+CPu85m/49PwmKmuGWTjICl2irFQF314v7pIPnAJtCxGqrjSofGU1xuU1yBs+RWbUna9PqdK7bDoxPTgzmNs6XdVvnTzbQKzteVBusJynowIvFNiKhONxA+2orkVx+wGU5wkXpfZsPTOJN3e6xMmwfCEf4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784672007; c=relaxed/simple; bh=oAbHZsu6+gXLfjpoNc3B11QDhtg3+IUaWC7/u56Z9A0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mTEgOrDg8WpNZ0c7xeyH2d1e5GcG+bXY1m5yxE4lP8kezx9jjWpg5msec0KzTeRvTS+bGSMuDZAt5Ht72jZ08qAzkseFPIVkeUP5kuR4WNHb+Z6tRkNa7MXYuondMVyieXnzt+MXAHUL7C/v7zV5p/DDpFpAuPAIlhrypD0ySaU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=o8Obk8LC; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="o8Obk8LC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C18111F00A3A; Tue, 21 Jul 2026 22:13:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784672005; bh=rLlnliQ8qUSa51cS4aGlk065v98U0BYcrsIQdO5XpcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=o8Obk8LCEvnXGnPSdXt/fJbpXmjezhUTPAB7+d6bI3lXa3cqHDfczSq+mjUq0BNEY Mr0T6a5x9bx1F5jIKM984JBQhaOnMq2crhDtdZ4j7OEoItAG6kBSAyN5ur7P08P0Hq 2UsH3Mg4ch+mMJISu7U8HiF1SV6VTMuyEBa2obhw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Manivannan Sadhasivam , Manivannan Sadhasivam , Bjorn Helgaas , Koichiro Den , Frank Li , Sasha Levin Subject: [PATCH 5.15 462/843] PCI: endpoint: pci-epf-vntb: Add check to detect db_count value of 0 Date: Tue, 21 Jul 2026 17:21:37 +0200 Message-ID: <20260721152416.425918910@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Manivannan Sadhasivam [ Upstream commit 33bd1ea748bc897c4d13437284e08c658e8d1340 ] epf_ntb->db_count value should be within 1 to MAX_DB_COUNT. Current code only checks for the upper bound, while the lower bound is unchecked. This can cause a lot of issues in the driver if the user passes 'db_count' as 0. Add a check for 0 also. While at it, remove the redundant 'db_count' assignment. Fixes: e35f56bb0330 ("PCI: endpoint: Support NTB transfer between RC and EP") Signed-off-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam Signed-off-by: Bjorn Helgaas Reviewed-by: Koichiro Den Reviewed-by: Frank Li Link: https://patch.msgid.link/20260407124421.282766-2-mani@kernel.org Signed-off-by: Sasha Levin --- drivers/pci/endpoint/functions/pci-epf-vntb.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c index e9402b5dc83598..48e4bfe6f32fad 100644 --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c @@ -475,7 +475,6 @@ static int epf_ntb_configure_interrupt(struct epf_ntb *ntb) { const struct pci_epc_features *epc_features; struct device *dev; - u32 db_count; int ret; dev = &ntb->epf->dev; @@ -487,14 +486,12 @@ static int epf_ntb_configure_interrupt(struct epf_ntb *ntb) return -EINVAL; } - db_count = ntb->db_count; - if (db_count > MAX_DB_COUNT) { - dev_err(dev, "DB count cannot be more than %d\n", MAX_DB_COUNT); + if (!ntb->db_count || ntb->db_count > MAX_DB_COUNT) { + dev_err(dev, "DB count %d out of range (1 - %d)\n", + ntb->db_count, MAX_DB_COUNT); return -EINVAL; } - ntb->db_count = db_count; - if (epc_features->msi_capable) { ret = pci_epc_set_msi(ntb->epf->epc, ntb->epf->func_no, -- 2.53.0