static analysis bug report: staging r8712u memcpy of uninitialized variable

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

 



Hi,

Static analysis with cppcheck found a couple of interesting issues with
memcpy'ing of an uninitialized variable. Two occurrences of the same
issue are found in drivers/staging/rtl8712/rtl8712_cmd.c in functions
read_bbreg_hdl and read_rfreg_hdl.

For example:

static u8 read_bbreg_hdl(struct _adapter *padapter, u8 *pbuf)
{
        u32 val;
        void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj
*pcmd);
        struct cmd_obj *pcmd  = (struct cmd_obj *)pbuf;

        if (pcmd->rsp && pcmd->rspsz > 0)
                memcpy(pcmd->rsp, (u8 *)&val, pcmd->rspsz);

	....

}

I don't understand why the contents of val is being memcpy'd to
pcmd->rsp, especially when val is uninitialized and hence contains
garbage. Any ideas?

Colin
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [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