1
0
Fork 0

media: mxl111sf: Fix potential null pointer dereference

Reviewing the delta between cppcheck output of v4.9.39 and v4.9.40
stable updates, I stumbled on the new warning:

mxl111sf.c:80: (warning) Possible null pointer dereference: rbuf

Since copying state->rcvbuf into rbuf is not needed in the 'write-only'
scenario (i.e. calling mxl111sf_ctrl_msg() from mxl111sf_i2c_send_data()
or from mxl111sf_write_reg()), bypass memcpy() in this case.

Fixes: d90b336f3f ("[media] mxl111sf: Fix driver to use heap allocate buffers for USB messages")

Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
hifive-unleashed-5.1
Eugeniu Rosca 2017-08-13 06:06:29 -04:00 committed by Mauro Carvalho Chehab
parent 9793e1d214
commit 87e9201108
1 changed files with 3 additions and 1 deletions

View File

@ -77,7 +77,9 @@ int mxl111sf_ctrl_msg(struct mxl111sf_state *state,
dvb_usbv2_generic_rw(d, state->sndbuf, 1+wlen, state->rcvbuf,
rlen);
memcpy(rbuf, state->rcvbuf, rlen);
if (rbuf)
memcpy(rbuf, state->rcvbuf, rlen);
mutex_unlock(&state->msg_lock);
mxl_fail(ret);