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 0CB134C6E; Mon, 23 Jun 2025 13:42:40 +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=1750686160; cv=none; b=dkatbEHrtMdv6XYtx0Y6LJyYE1UcT8BXOTx/A9TUostypcNrxzvhRR/HNRd4BkhQiXd/js9XBBOmkqEcjlQ8J+aXoeDmf7esVbeO9vfQuxyUFuwhaUV0Cjl4jqu/sY27R6Ig91X/00vdInYogOSc5Pz1Gm3ha/lf994WgcO44TI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750686160; c=relaxed/simple; bh=mNZLI9ulMMzZqd9dLwzWvOMYcD23vwtCCe/luIIOmCw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ekyImQ7ADhz0umYX2kuJ4R+oNHSRMRL91cIOGqdnLi6SMXDvnmtcg0/hKzm883UE7obRQL8spWHbD4dw/WkqJa6sv+qU/TLLtxPi/NzIT1SHN7HjPMDa8xUBiQfAvKO4t4PdHInNrpfzCZECKgZa/IVNg+TXvwjYwKZliHhK4Nc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=mhnp45PN; 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="mhnp45PN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96C98C4CEEA; Mon, 23 Jun 2025 13:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750686159; bh=mNZLI9ulMMzZqd9dLwzWvOMYcD23vwtCCe/luIIOmCw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mhnp45PNZG0/u2Ja/UXr3hYV/nxNaaKekTu1UDWh9akxqzR6DY1Wyl4gTavHXCDMF 2EpEYZlM+isZynvxOr/e6mlWWLOHe1lOPQ9J46um1w1Gl7F7sZ1EcWAIDd8eKmo1HG XbCMCf5Yq28RCtvDrILlxFfbIcPlN12H0KrhmMOM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ming Qian , Nicolas Dufresne , Frank Li , Hans Verkuil Subject: [PATCH 6.6 044/290] media: imx-jpeg: Reset slot data pointers when freed Date: Mon, 23 Jun 2025 15:05:05 +0200 Message-ID: <20250623130628.334216962@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130626.910356556@linuxfoundation.org> References: <20250623130626.910356556@linuxfoundation.org> User-Agent: quilt/0.68 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: Ming Qian commit faa8051b128f4b34277ea8a026d02d83826f8122 upstream. Ensure that the slot data pointers are reset to NULL and handles are set to 0 after freeing the coherent memory. This makes he function mxc_jpeg_alloc_slot_data() and mxc_jpeg_free_slot_data() safe to be called multiple times. Fixes: 2db16c6ed72c ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder") Cc: stable@vger.kernel.org Signed-off-by: Ming Qian Reviewed-by: Nicolas Dufresne Reviewed-by: Frank Li Signed-off-by: Nicolas Dufresne Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c @@ -758,16 +758,22 @@ static void mxc_jpeg_free_slot_data(stru dma_free_coherent(jpeg->dev, sizeof(struct mxc_jpeg_desc), jpeg->slot_data.desc, jpeg->slot_data.desc_handle); + jpeg->slot_data.desc = NULL; + jpeg->slot_data.desc_handle = 0; /* free descriptor for encoder configuration phase / decoder DHT */ dma_free_coherent(jpeg->dev, sizeof(struct mxc_jpeg_desc), jpeg->slot_data.cfg_desc, jpeg->slot_data.cfg_desc_handle); + jpeg->slot_data.cfg_desc_handle = 0; + jpeg->slot_data.cfg_desc = NULL; /* free configuration stream */ dma_free_coherent(jpeg->dev, MXC_JPEG_MAX_CFG_STREAM, jpeg->slot_data.cfg_stream_vaddr, jpeg->slot_data.cfg_stream_handle); + jpeg->slot_data.cfg_stream_vaddr = NULL; + jpeg->slot_data.cfg_stream_handle = 0; jpeg->slot_data.used = false; }