On Thu, Mar 21, 2019 at 09:26:38AM +0300, Dan Carpenter wrote: > Colin King reported a bug in read_bbreg_hdl(): > > memcpy(pcmd->rsp, (u8 *)&val, pcmd->rspsz); > > The problem is that "val" is uninitialized. > > This code is obviously not useful, but so far as I can tell > "pcmd->cmdcode" is never GEN_CMD_CODE(_Read_BBREG) so it's not harmful > either. For now the easiest fix is to just call r8712_free_cmd_obj() > and return. > > Fixes: 2865d42c78a9 ("staging: r8712u: Add the new driver to the mainline kernel") > Reported-by: Colin Ian King <colin.king@xxxxxxxxxxxxx> > Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> > --- > drivers/staging/rtl8712/rtl8712_cmd.c | 10 +--------- > drivers/staging/rtl8712/rtl8712_cmd.h | 2 +- > 2 files changed, 2 insertions(+), 10 deletions(-) > > diff --git a/drivers/staging/rtl8712/rtl8712_cmd.h b/drivers/staging/rtl8712/rtl8712_cmd.h > index 92fb77666d44..1ef86b8c592f 100644 > --- a/drivers/staging/rtl8712/rtl8712_cmd.h > +++ b/drivers/staging/rtl8712/rtl8712_cmd.h > @@ -140,7 +140,7 @@ enum rtl8712_h2c_cmd { > static struct _cmd_callback cmd_callback[] = { > {GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/ > {GEN_CMD_CODE(_Write_MACREG), NULL}, > - {GEN_CMD_CODE(_Read_BBREG), &r8712_getbbrfreg_cmdrsp_callback}, > + {GEN_CMD_CODE(_Read_BBREG), NULL}, > {GEN_CMD_CODE(_Write_BBREG), NULL}, > {GEN_CMD_CODE(_Read_RFREG), &r8712_getbbrfreg_cmdrsp_callback}, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > {GEN_CMD_CODE(_Write_RFREG), NULL}, /*5*/ The other place that calls r8712_getbbrfreg_cmdrsp_callback() is read_rfreg_hdl(). For GEN_CMD_CODE(_Read_RFREG) we don't allocate the ->rsp pointer so we can't kfree() it. The read_rfreg_hdl() functions calls r8712_free_cmd_obj() which kfrees it. But fortunately that is dead code. This code is obviously staging code... It would be fairly straight forward to get rid of the cmd_callback[] array. regards, dan carpenter _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel