* [PATCH] media: allegro: add the missed check for v4l2_m2m_ctx_init
@ 2019-12-09 8:58 Chuhong Yuan
2019-12-09 15:22 ` Michael Tretter
2019-12-09 18:54 ` Dan Carpenter
0 siblings, 2 replies; 3+ messages in thread
From: Chuhong Yuan @ 2019-12-09 8:58 UTC (permalink / raw)
Cc: Michael Tretter, Pengutronix Kernel Team, Mauro Carvalho Chehab,
Greg Kroah-Hartman, Hans Verkuil, linux-media, devel,
linux-kernel, Chuhong Yuan
allegro_open() misses a check for v4l2_m2m_ctx_init().
Add a check and error handling code to fix it.
Fixes: f20387dfd065 ("media: allegro: add Allegro DVT video IP core driver")
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
drivers/staging/media/allegro-dvt/allegro-core.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/staging/media/allegro-dvt/allegro-core.c b/drivers/staging/media/allegro-dvt/allegro-core.c
index 6f0cd0784786..5f1d454b41bb 100644
--- a/drivers/staging/media/allegro-dvt/allegro-core.c
+++ b/drivers/staging/media/allegro-dvt/allegro-core.c
@@ -2341,6 +2341,13 @@ static int allegro_open(struct file *file)
channel->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, channel,
allegro_queue_init);
+ if (IS_ERR(channel->fh.m2m_ctx)) {
+ v4l2_fh_del(&channel->fh);
+ v4l2_fh_exit(&channel->fh);
+ kfree(channel);
+ return PTR_ERR(channel->fh.m2m_ctx);
+ }
+
return 0;
}
--
2.24.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] media: allegro: add the missed check for v4l2_m2m_ctx_init
2019-12-09 8:58 [PATCH] media: allegro: add the missed check for v4l2_m2m_ctx_init Chuhong Yuan
@ 2019-12-09 15:22 ` Michael Tretter
2019-12-09 18:54 ` Dan Carpenter
1 sibling, 0 replies; 3+ messages in thread
From: Michael Tretter @ 2019-12-09 15:22 UTC (permalink / raw)
To: Chuhong Yuan
Cc: Pengutronix Kernel Team, Mauro Carvalho Chehab,
Greg Kroah-Hartman, Hans Verkuil, linux-media, devel,
linux-kernel
On Mon, 09 Dec 2019 16:58:07 +0800, Chuhong Yuan wrote:
> allegro_open() misses a check for v4l2_m2m_ctx_init().
> Add a check and error handling code to fix it.
>
> Fixes: f20387dfd065 ("media: allegro: add Allegro DVT video IP core driver")
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
Reviewed-by: Michael Tretter <m.tretter@pengutronix.de>
> ---
> drivers/staging/media/allegro-dvt/allegro-core.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/staging/media/allegro-dvt/allegro-core.c b/drivers/staging/media/allegro-dvt/allegro-core.c
> index 6f0cd0784786..5f1d454b41bb 100644
> --- a/drivers/staging/media/allegro-dvt/allegro-core.c
> +++ b/drivers/staging/media/allegro-dvt/allegro-core.c
> @@ -2341,6 +2341,13 @@ static int allegro_open(struct file *file)
> channel->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, channel,
> allegro_queue_init);
>
> + if (IS_ERR(channel->fh.m2m_ctx)) {
> + v4l2_fh_del(&channel->fh);
> + v4l2_fh_exit(&channel->fh);
> + kfree(channel);
> + return PTR_ERR(channel->fh.m2m_ctx);
> + }
> +
> return 0;
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] media: allegro: add the missed check for v4l2_m2m_ctx_init
2019-12-09 8:58 [PATCH] media: allegro: add the missed check for v4l2_m2m_ctx_init Chuhong Yuan
2019-12-09 15:22 ` Michael Tretter
@ 2019-12-09 18:54 ` Dan Carpenter
1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2019-12-09 18:54 UTC (permalink / raw)
To: Chuhong Yuan
Cc: devel, Greg Kroah-Hartman, Michael Tretter, linux-kernel,
Hans Verkuil, Pengutronix Kernel Team, Mauro Carvalho Chehab,
linux-media
On Mon, Dec 09, 2019 at 04:58:07PM +0800, Chuhong Yuan wrote:
> diff --git a/drivers/staging/media/allegro-dvt/allegro-core.c b/drivers/staging/media/allegro-dvt/allegro-core.c
> index 6f0cd0784786..5f1d454b41bb 100644
> --- a/drivers/staging/media/allegro-dvt/allegro-core.c
> +++ b/drivers/staging/media/allegro-dvt/allegro-core.c
> @@ -2341,6 +2341,13 @@ static int allegro_open(struct file *file)
> channel->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, channel,
> allegro_queue_init);
>
> + if (IS_ERR(channel->fh.m2m_ctx)) {
> + v4l2_fh_del(&channel->fh);
> + v4l2_fh_exit(&channel->fh);
> + kfree(channel);
^^^^^^^
Free
> + return PTR_ERR(channel->fh.m2m_ctx);
^^^^^^^^^^^^^^^^^^^
Dereferencing freed memory.
regards,
dan carpenter
> + }
> +
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-12-09 18:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-09 8:58 [PATCH] media: allegro: add the missed check for v4l2_m2m_ctx_init Chuhong Yuan
2019-12-09 15:22 ` Michael Tretter
2019-12-09 18:54 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).