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 F1BC83370FA; Fri, 17 Oct 2025 15:07:35 +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=1760713656; cv=none; b=IbjwUQYDevlGzP+D1FxdlrvW2jyHICghNKrVG2Y3vFUXlx4UU6Pb2+cpobHrTAf4hI0vuINR31jsE2xEa4govfKAhHn/L+2AfWSI/c9xgOhj5TT4hBAlVPMiYsmy37TegBsUEGL5i34gk0WGrRYqWKryP4mSWgmkpVheXYPM50w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760713656; c=relaxed/simple; bh=UUhodY3zxHQ4gxuIxgj61kBAp3jtUOkkS8rpFFefqfE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VKpbgYVznoNRAEU1r4PGcakTMcjffMnhU2ySlcC0VDiBLDJwmmtgLr+IRdijU9OlywvcUMArlsKMC//DjQdBzFklmUaXRExgpX2pmisiMJvDxs2/7EqtvNeLxztN1xpZ9tSofZ1Rbsxs22srmv/yFJYick3lBMmcvoy8yk9WP74= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=cjWPgWz1; 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="cjWPgWz1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FF50C4CEE7; Fri, 17 Oct 2025 15:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1760713655; bh=UUhodY3zxHQ4gxuIxgj61kBAp3jtUOkkS8rpFFefqfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cjWPgWz1wuQwhEpzEl+yOVxX9Ur5AcwgE7KSG/CxosXkfskWpMYoDpEBOtItIgZdM q3WKcqRGK/JRflZh4qSKQ2o0alhDOvl4iQkPpIUSxczZAMSJYRZurMku/UOcmWHE8K oeOtp4txb/S/OfO0H/kL6MSUj+wI8OwsPdK01sec= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thomas Fourier , Hans Verkuil Subject: [PATCH 6.6 072/201] media: cx18: Add missing check after DMA map Date: Fri, 17 Oct 2025 16:52:13 +0200 Message-ID: <20251017145137.401685168@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251017145134.710337454@linuxfoundation.org> References: <20251017145134.710337454@linuxfoundation.org> User-Agent: quilt/0.69 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-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Fourier commit 23b53639a793477326fd57ed103823a8ab63084f upstream. The DMA map functions can fail and should be tested for errors. If the mapping fails, dealloc buffers, and return. Fixes: 1c1e45d17b66 ("V4L/DVB (7786): cx18: new driver for the Conexant CX23418 MPEG encoder chip") Cc: stable@vger.kernel.org Signed-off-by: Thomas Fourier Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/pci/cx18/cx18-queue.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- a/drivers/media/pci/cx18/cx18-queue.c +++ b/drivers/media/pci/cx18/cx18-queue.c @@ -379,15 +379,22 @@ int cx18_stream_alloc(struct cx18_stream break; } + buf->dma_handle = dma_map_single(&s->cx->pci_dev->dev, + buf->buf, s->buf_size, + s->dma); + if (dma_mapping_error(&s->cx->pci_dev->dev, buf->dma_handle)) { + kfree(buf->buf); + kfree(mdl); + kfree(buf); + break; + } + INIT_LIST_HEAD(&mdl->list); INIT_LIST_HEAD(&mdl->buf_list); mdl->id = s->mdl_base_idx; /* a somewhat safe value */ cx18_enqueue(s, mdl, &s->q_idle); INIT_LIST_HEAD(&buf->list); - buf->dma_handle = dma_map_single(&s->cx->pci_dev->dev, - buf->buf, s->buf_size, - s->dma); cx18_buf_sync_for_cpu(s, buf); list_add_tail(&buf->list, &s->buf_pool); }