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 6E004AD49 for ; Wed, 4 Jan 2023 16:15:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3195C433EF; Wed, 4 Jan 2023 16:15:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672848908; bh=MimaLMWi5ZRbnPPy0T/5UcHq4lgxAWRPmd8ZHeCPtAY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DPEyEPGBy0bKJyPD3WpmkjFL1Diu+849jhS94s0RimXCQcBHhouX8k/p1JGzcGPtM PVt8ALH0izH2Krqt1GP7W9cBjR4RG/ykb5q2GYWTX9AO33yI2KvY5vCr8deCaFHsgE Rtk0IWIvTfsJn1Nn0uIaGUFIXhNy+xtUS/MIOsl0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, linux-fsd@tesla.com, Smitha T Murthy , Hans Verkuil Subject: [PATCH 6.0 033/177] media: s5p-mfc: Clear workbit to handle error condition Date: Wed, 4 Jan 2023 17:05:24 +0100 Message-Id: <20230104160508.669049097@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230104160507.635888536@linuxfoundation.org> References: <20230104160507.635888536@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Smitha T Murthy commit d3f3c2fe54e30b0636496d842ffbb5ad3a547f9b upstream. During error on CLOSE_INSTANCE command, ctx_work_bits was not getting cleared. During consequent mfc execution NULL pointer dereferencing of this context led to kernel panic. This patch fixes this issue by making sure to clear ctx_work_bits always. Fixes: 818cd91ab8c6 ("[media] s5p-mfc: Extract open/close MFC instance commands") Cc: stable@vger.kernel.org Cc: linux-fsd@tesla.com Signed-off-by: Smitha T Murthy Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c @@ -468,8 +468,10 @@ void s5p_mfc_close_mfc_inst(struct s5p_m s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); /* Wait until instance is returned or timeout occurred */ if (s5p_mfc_wait_for_done_ctx(ctx, - S5P_MFC_R2H_CMD_CLOSE_INSTANCE_RET, 0)) + S5P_MFC_R2H_CMD_CLOSE_INSTANCE_RET, 0)){ + clear_work_bit_irqsave(ctx); mfc_err("Err returning instance\n"); + } /* Free resources */ s5p_mfc_hw_call(dev->mfc_ops, release_codec_buffers, ctx);