From: Zhipeng Lu <alexious@zju.edu.cn>
To: alexious@zju.edu.cn
Cc: Hans de Goede <hdegoede@redhat.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Kate Hsuan <hpa@redhat.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Dan Carpenter <error27@gmail.com>,
Brent Pappas <bpappas@pappasbrent.com>,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: [PATCH] media: atomisp: ssh_css: Fix a null-pointer dereference in load_video_binaries
Date: Fri, 12 Jan 2024 16:34:19 +0800 [thread overview]
Message-ID: <20240112083421.3728017-1-alexious@zju.edu.cn> (raw)
The allocation failure of mycs->yuv_scaler_binary in load_video_binaries
is followed with a dereference of mycs->yuv_scaler_binary after the
following call chain:
sh_css_pipe_load_binaries
|-> load_video_binaries (mycs->yuv_scaler_binary == NULL)
|
|-> sh_css_pipe_unload_binaries
|-> unload_video_binaries
In unload_video_binaries, it calls to ia_css_binary_unload with argument
&pipe->pipe_settings.video.yuv_scaler_binary[i], which refers to the
same memory slot as mycs->yuv_scaler_binary. Thus, a null-pointer
dereference is triggered.
Fixes: ad85094b293e ("Revert "media: staging: atomisp: Remove driver"")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
---
drivers/staging/media/atomisp/pci/sh_css.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/sh_css.c b/drivers/staging/media/atomisp/pci/sh_css.c
index f35c90809414..eb43f4e99d02 100644
--- a/drivers/staging/media/atomisp/pci/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/sh_css.c
@@ -4936,9 +4936,10 @@ unload_video_binaries(struct ia_css_pipe *pipe)
ia_css_binary_unload(&pipe->pipe_settings.video.video_binary);
ia_css_binary_unload(&pipe->pipe_settings.video.vf_pp_binary);
- for (i = 0; i < pipe->pipe_settings.video.num_yuv_scaler; i++)
- ia_css_binary_unload(&pipe->pipe_settings.video.yuv_scaler_binary[i]);
-
+ if (pipe->pipe_settings.video.yuv_scaler_binary)
+ for (i = 0; i < pipe->pipe_settings.video.num_yuv_scaler; i++)
+ ia_css_binary_unload(&pipe->pipe_settings.video.yuv_scaler_binary[i]);
+
kfree(pipe->pipe_settings.video.is_output_stage);
pipe->pipe_settings.video.is_output_stage = NULL;
kfree(pipe->pipe_settings.video.yuv_scaler_binary);
--
2.34.1
next reply other threads:[~2024-01-12 8:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-12 8:34 Zhipeng Lu [this message]
2024-01-12 8:49 ` Hans de Goede
2024-01-12 18:27 ` Andy Shevchenko
[not found] ` <17d22c9e.4900.18d162090d8.Coremail.alexious@zju.edu.cn>
2024-01-17 20:50 ` Andy Shevchenko
2024-01-18 15:10 ` alexious
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=20240112083421.3728017-1-alexious@zju.edu.cn \
--to=alexious@zju.edu.cn \
--cc=andy.shevchenko@gmail.com \
--cc=bpappas@pappasbrent.com \
--cc=error27@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=hpa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--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®