media: atomisp: ssh_css: Fix a null-pointer dereference in load_video_binaries
Subsystems (4)
PATCH v2 1/1 media: atomisp: ssh_css: Fix a null-pointer dereference in load_video_binaries
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_binariesIn 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.
---
Changelog:
v2: change fix approach to set mycs->num_yuv_scaler = 0 in load_video_binaries. Change the fix tag to correct commit.
--- drivers/staging/media/atomisp/pci/sh_css.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/media/atomisp/pci/sh_css.c +1 -0
@@ -4719,6 +4719,7 @@ static int load_video_binaries(struct ia_css_pipe *pipe)sizeof (struct ia_css_binary ), GFP_KERNEL);if (!mycs->yuv_scaler_binary) { + mycs->num_yuv_scaler =0 ; err = -ENOMEM ;return err; }
Signature · 1 line
2.34.1
Quoted 11 lines · Zhipeng Lu
The allocation failure of
mycs->yuv_scaler_binaryinload_video_binariesis followed with a dereference ofmycs->yuv_scaler_binaryafter 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
Quoted 4 lines
In
unload_video_binaries, it calls toia_css_binary_unloadwith argument &pipe->pipe_settings.video.yuv_scaler_binary[i], which refers to the same memory slot asmycs->yuv_scaler_binary. Thus, a null-pointer dereference is triggered.
Good for me now, thank you.
P.S. If needed, or Hans can do it, the references to the functions can be amended in the commit message as we use the 'func()' format (w/o quotes).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hans de Goede
AppliedHi,
Quoted 15 lines · Zhipeng Lu
The allocation failure of
mycs->yuv_scaler_binaryinload_video_binariesis followed with a dereference ofmycs->yuv_scaler_binaryafter the following call chain:
sh_css_pipe_load_binaries|-> load_video_binaries (mycs->yuv_scaler_binary == NULL) | |-> sh_css_pipe_unload_binaries |-> unload_video_binariesIn
unload_video_binaries, it calls toia_css_binary_unloadwith argument &pipe->pipe_settings.video.yuv_scaler_binary[i], which refers to the same memory slot asmycs->yuv_scaler_binary. Thus, a null-pointer dereference is triggered.
Quoted 7 lines
Fixes a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")Signed-off-by Zhipeng Lu <[email protected]>---
Changelog:v2: change fix approach to set
mycs->num_yuv_scaler= 0 inload_video_binaries. Change the fix tag to correct commit.
Thank you for you patch.
I have applied this patch to my media-atomip branch:
https://git.kernel.org/pub/scm/linux/kernel/git/hansg/linux.git/log/?h=media-atomisp
and I will include this in my next media-atomisp
pull-request to Mauro.
Regards,
Hans
Quoted 16 lines
--- drivers/staging/media/atomisp/pci/sh_css.c | 1 + 1 file changed, 1 insertion(+)drivers/staging/media/atomisp/pci/sh_css.c +1
-0@@ -4719,6 +4719,7 @@ static int load_video_binaries(struct ia_css_pipe *pipe)sizeof (struct ia_css_binary ), GFP_KERNEL);if (!mycs->yuv_scaler_binary) { + mycs->num_yuv_scaler =0 ; err = -ENOMEM ;return err; }