mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel@pengutronix.de
Subject: Re: [PATCH 1/2] media: video-mux: fix error paths
Date: Tue, 30 May 2023 19:47:12 +0300	[thread overview]
Message-ID: <20230530164712.GB22516@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20230524-video-mux-active-state-v1-1-325c69937ac3@pengutronix.de>

Hi Philipp,

Thank you for the patch.

On Wed, May 24, 2023 at 03:29:24PM +0200, Philipp Zabel wrote:
> Move notifier cleanup into video_mux_async_register() to avoid calling
> v4l2_async_nf_unregister() when v4l2_async_subdev_nf_register() failed.
> In case video_mux_async_register() fails, call media_entity_cleanup().
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/media/platform/video-mux.c | 26 +++++++++++++++++++-------
>  1 file changed, 19 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c
> index 1d9f32e5a917..4fe31386afc7 100644
> --- a/drivers/media/platform/video-mux.c
> +++ b/drivers/media/platform/video-mux.c
> @@ -389,7 +389,7 @@ static int video_mux_async_register(struct video_mux *vmux,
>  			ret = PTR_ERR(asd);
>  			/* OK if asd already exists */
>  			if (ret != -EEXIST)
> -				return ret;
> +				goto err_nf_cleanup;
>  		}
>  	}
>  
> @@ -397,9 +397,19 @@ static int video_mux_async_register(struct video_mux *vmux,
>  
>  	ret = v4l2_async_subdev_nf_register(&vmux->subdev, &vmux->notifier);
>  	if (ret)
> -		return ret;
> +		goto err_nf_cleanup;
>  
> -	return v4l2_async_register_subdev(&vmux->subdev);
> +	ret = v4l2_async_register_subdev(&vmux->subdev);
> +	if (ret)
> +		goto err_nf_unregister;
> +
> +	return 0;
> +
> +err_nf_unregister:
> +	v4l2_async_nf_unregister(&vmux->notifier);
> +err_nf_cleanup:
> +	v4l2_async_nf_cleanup(&vmux->notifier);
> +	return ret;
>  }
>  
>  static int video_mux_probe(struct platform_device *pdev)
> @@ -473,11 +483,13 @@ static int video_mux_probe(struct platform_device *pdev)
>  	vmux->subdev.entity.ops = &video_mux_ops;
>  
>  	ret = video_mux_async_register(vmux, num_pads - 1);
> -	if (ret) {
> -		v4l2_async_nf_unregister(&vmux->notifier);
> -		v4l2_async_nf_cleanup(&vmux->notifier);
> -	}
> +	if (ret)
> +		goto err_entity_cleanup;
>  
> +	return 0;
> +
> +err_entity_cleanup:
> +	media_entity_cleanup(&vmux->subdev.entity);
>  	return ret;
>  }
>  
> 

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2023-05-30 16:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-24 13:29 [PATCH 0/2] media: video-mux: fix error paths and update to active state Philipp Zabel
2023-05-24 13:29 ` [PATCH 1/2] media: video-mux: fix error paths Philipp Zabel
2023-05-30 16:47   ` Laurent Pinchart [this message]
2023-05-24 13:29 ` [PATCH 2/2] media: video-mux: update driver to active state Philipp Zabel
2023-05-30 16:55   ` Laurent Pinchart
2023-08-02 13:15   ` Jacopo Mondi
2023-08-03 22:27     ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230530164712.GB22516@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®