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 107B1429037; Mon, 17 Aug 2026 15:11:01 +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=1786979462; cv=none; b=bQzGxrOc0ecB6mwHjen2HjO9J1tjrgw0H8/G+su1fP7teprO6hsoLbbCeFokKk9hGjELqV6ShAQjQXqaD8+drXaX3wZw5yIzVD9bLzW8jxZuTI/xnJmmoWr7xzN18Od6WIKzBHvUeIhycN4blD/lf6cN4qhWXLW8Jy+RSb07epE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786979462; c=relaxed/simple; bh=uC6hZsCwquLELuTQjfNARvvDBqHg1tJ977w/5rMgikQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=InHM3d4YZyykDMcS4mf26q+amIOzuTF+gVBq+/wUljXvDG955szUo9Enk4T7/dJKO5E7HLTaYEtFLo4WIHNCN7T01o/N0ov6nUbMHuRcDSy9bMIEEaHscjl8zFD3ciste8EvKd5Q4EHiIqGREpxQYU14MtkaCsjIdOopQ/NyPxI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=M6LnSPKV; 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="M6LnSPKV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94B181F000E9; Mon, 17 Aug 2026 15:11:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786979461; bh=EFzFKRJrzPtk/5T0sl7To1rI1UknZObxjiUgfxyZVNc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=M6LnSPKVa5vILhLgz249sTvP+9B+NZeqSOvgflUF4Mk19LQ6e4TVw/Zdkyjw/fFX2 13w0g8VYJ5xSBhQDbmKELypcDHLrazCVzgmQCyzvyEE+6Z/Yt6jqDaS3RZSb4qfMy2 qSSZeffkQpmPTHDCWbjHx9Qm3mQ/4lcrTx94thng= 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 6.1 195/609] media: cx23885: add ioremap return check and cleanup Date: Mon, 17 Aug 2026 15:28:11 +0200 Message-ID: <20260817132550.614674708@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132543.039278408@linuxfoundation.org> References: <20260817132543.039278408@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 6.1-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)