public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* static analysis bug report: staging r8712u memcpy of uninitialized variable
@ 2019-03-18 11:20 Colin Ian King
  2019-03-20  8:58 ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Colin Ian King @ 2019-03-18 11:20 UTC (permalink / raw)
  To: Larry Finger; +Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-21  6:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-18 11:20 static analysis bug report: staging r8712u memcpy of uninitialized variable Colin Ian King
2019-03-20  8:58 ` Dan Carpenter
2019-03-21  6:26   ` [PATCH] staging: rtl8712: uninitialized memory in read_bbreg_hdl() Dan Carpenter
2019-03-21  6:45     ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox