Re: [PATCH v2 1/2] media: atomisp: Fix smatch warnings caused by atomisp custom assert() usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 01, 2023 at 08:32:18PM +0800, Kate Hsuan wrote:
> > diff --git a/drivers/staging/media/atomisp/pci/sh_css_mipi.c b/drivers/staging/media/atomisp/pci/sh_css_mipi.c
> > index b20acaab0595..ced21dedf7ac 100644
> > --- a/drivers/staging/media/atomisp/pci/sh_css_mipi.c
> > +++ b/drivers/staging/media/atomisp/pci/sh_css_mipi.c
> > @@ -351,15 +351,6 @@ allocate_mipi_frames(struct ia_css_pipe *pipe,
> >         ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
> >                             "allocate_mipi_frames(%p) enter:\n", pipe);
> >
> > -       assert(pipe);
> > -       assert(pipe->stream);
> > -       if ((!pipe) || (!pipe->stream)) {
> > -               ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
> > -                                   "allocate_mipi_frames(%p) exit: pipe or stream is null.\n",
> > -                                   pipe);
> > -               return -EINVAL;
> > -       }
> 
> Thank you for working on this.
> 
> The NULL test for pipe could be kept here since the caller only tests
> "stream" but not test "main_pipe" is NULL. (sh_css.c line: 1799)
> 

It dereferences main_pipe on the next line so this check would be too
late.

drivers/staging/media/atomisp/pci/sh_css.c
  1799          main_pipe       = stream->last_pipe;
  1800          pipe_id = main_pipe->mode;

Smatch says that ->last_pipe is known to be non-NULL as well.

$ smdb.py create_host_pipeline
drivers/staging/media/atomisp/pci/sh_css.c |  ia_css_stream_start | create_host_pipeline |        PARAM_VALUE |  0 | stream->last_pipe | 4096-ptr_max

regards,
dan carpenter




[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux