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 2409732E13F; Mon, 27 Oct 2025 18:45:11 +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=1761590711; cv=none; b=HSoLo9lVmSDpe+VVlx+C0HJ6CtlKGOPemuZ8tmM3A7AmXpWh8mKWW9hKvnXUURTlzIig3syYFAINAc+2XyisxuXpA/U4HFfT1xRsDXss4W7SluHMJd4PfA8DNFR2gpHzIFfRJ2ltvtfVSjFJFHu5Tr5zZspT2s6F3aIZFptN4/A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761590711; c=relaxed/simple; bh=amKCLbOkzotOkBykWR7VTomttTKreAcimp/lqq4FpBk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A7S0kzA20o+uXihVxh/094DsYQ/Bs3vuaArINk+2TPnOTqXEEl49htznfnkkjTogdZmMgP5Qb1LFL0CMx7bcx6HLP1BF6n+FwLwXWE78P+bgvFTZIaKJ6VHRdSC3Ki9t5dni8NgJvmRkMed+QhICdfofr7vVUKMmeH5FGVjoMng= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=onEswFI7; 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="onEswFI7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A057C4CEFD; Mon, 27 Oct 2025 18:45:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761590710; bh=amKCLbOkzotOkBykWR7VTomttTKreAcimp/lqq4FpBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=onEswFI78zQbF5MlHcd8WcMXPfC/UKvi2U/Fe4WD4Z7h15vj1ZXPJlbdveBAM0/0L eVzgzg7tM7vVqM8r/DjNkH/vU74w3ncdVV5Bo1f9r6SUQdem4kBY/VqGgmW0lEVeZg qmraCAhUznweNLYrWB+B1HOv9mi9Gz/QjR4im5qw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thomas Fourier , Hans Verkuil , Sasha Levin Subject: [PATCH 5.4 149/224] media: cx18: Add missing check after DMA map Date: Mon, 27 Oct 2025 19:34:55 +0100 Message-ID: <20251027183512.956340832@linuxfoundation.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251027183508.963233542@linuxfoundation.org> References: <20251027183508.963233542@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Fourier [ Upstream commit 23b53639a793477326fd57ed103823a8ab63084f ] 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 [ removed pci_map_single() replaced by dma_map_single() ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/media/pci/cx18/cx18-queue.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/drivers/media/pci/cx18/cx18-queue.c +++ b/drivers/media/pci/cx18/cx18-queue.c @@ -379,14 +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 = pci_map_single(s->cx->pci_dev, - buf->buf, s->buf_size, s->dma); cx18_buf_sync_for_cpu(s, buf); list_add_tail(&buf->list, &s->buf_pool); }