* [PATCH] s5p-jpeg: Fix possible NULL pointer dereference in s_fmt
@ 2014-11-28 13:10 Jacek Anaszewski
2015-03-03 15:51 ` Sylwester Nawrocki
0 siblings, 1 reply; 2+ messages in thread
From: Jacek Anaszewski @ 2014-11-28 13:10 UTC (permalink / raw)
To: linux-media; +Cc: s.nawrocki, Jacek Anaszewski
Some formats are not supported in encoding or decoding
mode for given type of buffer (e.g. V4L2_PIX_FMT_JPEG
is supported on output buffer only while in decoding
mode). Make S_FMT failing if not suitable format
is found.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
---
drivers/media/platform/s5p-jpeg/jpeg-core.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index d7571cd..dfab848 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -1345,6 +1345,14 @@ static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f)
FMT_TYPE_OUTPUT : FMT_TYPE_CAPTURE;
q_data->fmt = s5p_jpeg_find_format(ct, pix->pixelformat, f_type);
+
+ if (!q_data->fmt) {
+ v4l2_err(&ct->jpeg->v4l2_dev,
+ "Fourcc format (0x%08x) invalid.\n",
+ f->fmt.pix.pixelformat);
+ return -EINVAL;
+ }
+
q_data->w = pix->width;
q_data->h = pix->height;
if (q_data->fmt->fourcc != V4L2_PIX_FMT_JPEG) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] s5p-jpeg: Fix possible NULL pointer dereference in s_fmt
2014-11-28 13:10 [PATCH] s5p-jpeg: Fix possible NULL pointer dereference in s_fmt Jacek Anaszewski
@ 2015-03-03 15:51 ` Sylwester Nawrocki
0 siblings, 0 replies; 2+ messages in thread
From: Sylwester Nawrocki @ 2015-03-03 15:51 UTC (permalink / raw)
To: Jacek Anaszewski; +Cc: linux-media
Hi Jacek,
On 28/11/14 14:10, Jacek Anaszewski wrote:
> Some formats are not supported in encoding or decoding
> mode for given type of buffer (e.g. V4L2_PIX_FMT_JPEG
> is supported on output buffer only while in decoding
> mode). Make S_FMT failing if not suitable format
> is found.
>
> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
> ---
> drivers/media/platform/s5p-jpeg/jpeg-core.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
> index d7571cd..dfab848 100644
> --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
> +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
> @@ -1345,6 +1345,14 @@ static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f)
> FMT_TYPE_OUTPUT : FMT_TYPE_CAPTURE;
>
> q_data->fmt = s5p_jpeg_find_format(ct, pix->pixelformat, f_type);
> +
> + if (!q_data->fmt) {
> + v4l2_err(&ct->jpeg->v4l2_dev,
> + "Fourcc format (0x%08x) invalid.\n",
> + f->fmt.pix.pixelformat);
> + return -EINVAL;
> + }
> +
How about forcing one of valid formats instead ? VIDIOC_S_FMT is not
supposed to return an error just because a not supported fourcc
was passed from user space.
--
Thanks,
Sylwester
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-03 15:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-28 13:10 [PATCH] s5p-jpeg: Fix possible NULL pointer dereference in s_fmt Jacek Anaszewski
2015-03-03 15:51 ` Sylwester Nawrocki
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).