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 7C1403E025C; Mon, 17 Aug 2026 14:08:39 +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=1786975720; cv=none; b=QA1jggk3r+4PKppRmXrFhsgUc6aLwVTcXD1w6JOZIDAm92mW40GT+FrHU88/t9SrW3wY5mqepnh3vQOmB1ev1O7nTCSsQoeqXKJaiFRA/cSOlDGaWpfVpBdP8Ucno9o7fQoIxU8htzJgiRsE4px4EwOl6FlF6klHpjlcR4vp6+w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786975720; c=relaxed/simple; bh=v9NcA9E2cI8Vr21u4zpXPKcUrCuv1i+SNHKb6Nqducg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BZDUuWwjQDUnaeM37daPG1SW+GQ7j7kSeGZGMJUsbhYO4UFlv4uwGJyOjdLefr2QaOE3gAeiJQXHkB3VTaxrD3Tj7+Tsiuk0768eweXFT7HUzkotxxA1oyRWEXHkz6tzcI/YuUgywmHH4fxZOUwTEFM62W6hfJ6A37u56EeF7tw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hLKeqkYu; 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="hLKeqkYu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5FB11F000E9; Mon, 17 Aug 2026 14:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786975719; bh=CvBepDhfru4/T0Dv7JvHKaoyHGzhBtY13MhuSx4oXDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hLKeqkYuJc0mKMMyI14K5nFRznx6dkbxtk7n48wWlyLw9vCQKunjMK/o92VbPe+zC djR/fDkHn+m0LBVraBJfWd2Yd9X1YGxxYre2gYGsAou491AVQkMjEg33l+UXkAr32N 9ZPxxo/o7U85PSqciLjpYZYeQxTclnyCPD25Sr/k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wang Jun <1742789905@qq.com>, Hans Verkuil Subject: [PATCH 5.10 126/389] media: cx23885: add ioremap return check and cleanup Date: Mon, 17 Aug 2026 15:29:25 +0200 Message-ID: <20260817132544.076135788@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132538.796021292@linuxfoundation.org> References: <20260817132538.796021292@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.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wang Jun <1742789905@qq.com> commit a0701e387b46e2481c05b47f1235b954bfc2af3e upstream. Add a check for the return value of pci_ioremap_bar() in cx23885_dev_setup(). If ioremap for BAR0 fails, release the already allocated PCI memory region, decrement the device count, and return -ENODEV. This prevents a potential null pointer dereference and ensures proper cleanup on memory mapping failure. Fixes: d19770e5178a ("V4L/DVB (6150): Add CX23885/CX23887 PCIe bridge driver") Cc: stable@vger.kernel.org Signed-off-by: Wang Jun <1742789905@qq.com> Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/pci/cx23885/cx23885-core.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) --- a/drivers/media/pci/cx23885/cx23885-core.c +++ b/drivers/media/pci/cx23885/cx23885-core.c @@ -990,8 +990,12 @@ static int cx23885_dev_setup(struct cx23 } /* PCIe stuff */ - dev->lmmio = ioremap(pci_resource_start(dev->pci, 0), - pci_resource_len(dev->pci, 0)); + dev->lmmio = pci_ioremap_bar(dev->pci, 0); + if (!dev->lmmio) { + dev_err(&dev->pci->dev, "CORE %s: can't ioremap MMIO memory\n", + dev->name); + goto err_release_region; + } dev->bmmio = (u8 __iomem *)dev->lmmio; @@ -1096,6 +1100,12 @@ static int cx23885_dev_setup(struct cx23 } return 0; + +err_release_region: + release_mem_region(pci_resource_start(dev->pci, 0), + pci_resource_len(dev->pci, 0)); + cx23885_devcount--; + return -ENODEV; } static void cx23885_dev_unregister(struct cx23885_dev *dev)