[PATCH 6/6] media: staging: atomisp: Fix potential NULL pointer dereference

From: Pankaj Bharadiya
Date: Wed May 23 2018 - 00:33:59 EST


In verify_copy_out_frame_format(), "pipe" is being dereferenced before
it is null checked.
Fix it by moving the "pipe" pointer dereference after it has been
properly null checked.

Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@xxxxxxxxx>
---
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index eb84d51..487e768 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -455,12 +455,14 @@ static enum ia_css_frame_format yuv422_copy_formats[] = {
static enum ia_css_err
verify_copy_out_frame_format(struct ia_css_pipe *pipe)
{
- enum ia_css_frame_format out_fmt = pipe->output_info[0].format;
+ enum ia_css_frame_format out_fmt;
unsigned int i, found = 0;

assert(pipe != NULL);
assert(pipe->stream != NULL);

+ out_fmt = pipe->output_info[0].format;
+
switch (pipe->stream->config.input_config.format) {
case ATOMISP_INPUT_FORMAT_YUV420_8_LEGACY:
case ATOMISP_INPUT_FORMAT_YUV420_8:
--
2.7.4