diff mbox series

[v1,06/18] media: hantro: Make sure that ctx->codex_ops is set

Message ID 20210217080306.157876-7-benjamin.gaignard@collabora.com (mailing list archive)
State New
Headers show
Series Add HANTRO G2/HEVC decoder support for IMX8MQ | expand

Commit Message

Benjamin Gaignard Feb. 17, 2021, 8:02 a.m. UTC
Do not try to call ctx->codec_ops->done if ctx->codec_ops is not set.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
---
 drivers/staging/media/hantro/hantro_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ezequiel Garcia Feb. 17, 2021, 8:11 p.m. UTC | #1
On Wed, 2021-02-17 at 09:02 +0100, Benjamin Gaignard wrote:
> Do not try to call ctx->codec_ops->done if ctx->codec_ops is not set.
> 

If codec_ops is not set for a codec variant,
things will go south really fast. See hantro_start_streaming
for instance.

I think you can just drop this patch.

Thanks,
Ezequiel

> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
> Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
> ---
>  drivers/staging/media/hantro/hantro_drv.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c
> index 0d58209fc55c..0570047c7fa0 100644
> --- a/drivers/staging/media/hantro/hantro_drv.c
> +++ b/drivers/staging/media/hantro/hantro_drv.c
> @@ -93,7 +93,8 @@ void hantro_irq_done(struct hantro_dev *vpu,
>          * and will take care of finishing the job.
>          */
>         if (cancel_delayed_work(&vpu->watchdog_work)) {
> -               if (result == VB2_BUF_STATE_DONE && ctx->codec_ops->done)
> +               if (result == VB2_BUF_STATE_DONE &&
> +                   ctx->codec_ops && ctx->codec_ops->done)
>                         ctx->codec_ops->done(ctx);
>                 hantro_job_finish(vpu, ctx, result);
>         }
Dan Carpenter Feb. 18, 2021, 10:53 a.m. UTC | #2
On Wed, Feb 17, 2021 at 09:02:54AM +0100, Benjamin Gaignard wrote:
> Do not try to call ctx->codec_ops->done if ctx->codec_ops is not set.
> 

When you're writing a patch like this please say in the commit message
if this can happen or not.  Option 1:

Option 1: sometimes this is NULL in <some situation>
Option 2: this can't be NULL, but we are planning to allow that.
Option 3: I don't know if this can be NULL but do it for consistency

As we review and packport patches we have to figure out why you are
adding NULL checks so it really helps if you just tell us.

regards,
dan carpenter
diff mbox series

Patch

diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c
index 0d58209fc55c..0570047c7fa0 100644
--- a/drivers/staging/media/hantro/hantro_drv.c
+++ b/drivers/staging/media/hantro/hantro_drv.c
@@ -93,7 +93,8 @@  void hantro_irq_done(struct hantro_dev *vpu,
 	 * and will take care of finishing the job.
 	 */
 	if (cancel_delayed_work(&vpu->watchdog_work)) {
-		if (result == VB2_BUF_STATE_DONE && ctx->codec_ops->done)
+		if (result == VB2_BUF_STATE_DONE &&
+		    ctx->codec_ops && ctx->codec_ops->done)
 			ctx->codec_ops->done(ctx);
 		hantro_job_finish(vpu, ctx, result);
 	}