From: Colin Ian King <colin.king@canonical.com>
To: Larry Finger <Larry.Finger@lwfinger.net>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>
Subject: static analysis bug report: staging r8712u memcpy of uninitialized variable
Date: Mon, 18 Mar 2019 11:20:51 +0000 [thread overview]
Message-ID: <2b54dc2d-7509-dc76-b730-4c8d66f81226@canonical.com> (raw)
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
next reply other threads:[~2019-03-18 11:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-18 11:20 Colin Ian King [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2b54dc2d-7509-dc76-b730-4c8d66f81226@canonical.com \
--to=colin.king@canonical.com \
--cc=Larry.Finger@lwfinger.net \
--cc=devel@driverdev.osuosl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®