Message ID | 94488f55b92ab1567dfeaf1fffb12fecc8c0b1d0.1544188058.git.mchehab+samsung@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] media: pxa_camera: don't deferenciate a NULL pointer | expand |
On Fri, Dec 7, 2018 at 5:08 AM Mauro Carvalho Chehab <mchehab+samsung@kernel.org> wrote: > > There is a smatch warning: > drivers/media/dvb-frontends/drxk_hard.c: drivers/media/dvb-frontends/drxk_hard.c:1478 scu_command() error: we previously assumed 'parameter' could be null (see line 1467) > > Telling that parameter might be NULL. Well, it can't, due to the > way the driver works, but it doesn't hurt to add a check, in order > to shut up smatch. eh, yeah this function is kind of odd; the early return conditions are a little tricky, but I agree that this check doesn't hurt to add. Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > > Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> > --- > drivers/media/dvb-frontends/drxk_hard.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c > index 84ac3f73f8fe..8ea1e45be710 100644 > --- a/drivers/media/dvb-frontends/drxk_hard.c > +++ b/drivers/media/dvb-frontends/drxk_hard.c > @@ -1474,9 +1474,11 @@ static int scu_command(struct drxk_state *state, > > /* assume that the command register is ready > since it is checked afterwards */ > - for (ii = parameter_len - 1; ii >= 0; ii -= 1) { > - buffer[cnt++] = (parameter[ii] & 0xFF); > - buffer[cnt++] = ((parameter[ii] >> 8) & 0xFF); > + if (parameter) { > + for (ii = parameter_len - 1; ii >= 0; ii -= 1) { > + buffer[cnt++] = (parameter[ii] & 0xFF); > + buffer[cnt++] = ((parameter[ii] >> 8) & 0xFF); > + } > } > buffer[cnt++] = (cmd & 0xFF); > buffer[cnt++] = ((cmd >> 8) & 0xFF); > -- > 2.19.2 >
diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c index 84ac3f73f8fe..8ea1e45be710 100644 --- a/drivers/media/dvb-frontends/drxk_hard.c +++ b/drivers/media/dvb-frontends/drxk_hard.c @@ -1474,9 +1474,11 @@ static int scu_command(struct drxk_state *state, /* assume that the command register is ready since it is checked afterwards */ - for (ii = parameter_len - 1; ii >= 0; ii -= 1) { - buffer[cnt++] = (parameter[ii] & 0xFF); - buffer[cnt++] = ((parameter[ii] >> 8) & 0xFF); + if (parameter) { + for (ii = parameter_len - 1; ii >= 0; ii -= 1) { + buffer[cnt++] = (parameter[ii] & 0xFF); + buffer[cnt++] = ((parameter[ii] >> 8) & 0xFF); + } } buffer[cnt++] = (cmd & 0xFF); buffer[cnt++] = ((cmd >> 8) & 0xFF);
There is a smatch warning: drivers/media/dvb-frontends/drxk_hard.c: drivers/media/dvb-frontends/drxk_hard.c:1478 scu_command() error: we previously assumed 'parameter' could be null (see line 1467) Telling that parameter might be NULL. Well, it can't, due to the way the driver works, but it doesn't hurt to add a check, in order to shut up smatch. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> --- drivers/media/dvb-frontends/drxk_hard.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)