From: Johannes Berg <johannes@sipsolutions.net>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Wey-Yi Guy <wey-yi.w.guy@intel.com>,
Intel Linux Wireless <ilw@linux.intel.com>,
linux-wireless@vger.kernel.org
Subject: Re: [smatch stuff] question about iwlagn_rx_calib_result()
Date: Wed, 07 Dec 2011 10:07:13 +0100 [thread overview]
Message-ID: <1323248833.3404.7.camel@jlt3.sipsolutions.net> (raw)
In-Reply-To: <20111207085923.GA15304@elgon.mountain> (sfid-20111207_095943_156880_EC0FBF3D)
On Wed, 2011-12-07 at 11:59 +0300, Dan Carpenter wrote:
> Smatch complains about iwlagn_rx_calib_result() it would be bad for
> "len" to be negative.
>
> drivers/net/wireless/iwlwifi/iwl-ucode.c
>
> 299 int iwlagn_rx_calib_result(struct iwl_priv *priv,
> 300 struct iwl_rx_mem_buffer *rxb,
> 301 struct iwl_device_cmd *cmd)
> 302 {
> 303 struct iwl_rx_packet *pkt = rxb_addr(rxb);
> 304 struct iwl_calib_hdr *hdr = (struct iwl_calib_hdr *)pkt->u.raw;
> 305 int len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
> 306
> 307 /* reduce the size of the length field itself */
> 308 len -= 4;
> ^^^^^^^^
> Where does this 4 come from? I've tried to determine what the minimum
> size of "le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK" is but
> I got lost. Can it ever be less than 4?
4 is sizeof(struct iwl_cmd_header) I think.
If the frame size ends up <= 4, that would be a major uCode/device bug
since any frame has to start with len_n_flags & the header, of which the
len_n_flags isn't included (see struct iwl_rx_packet).
johannes
next prev parent reply other threads:[~2011-12-07 9:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-07 8:59 [smatch stuff] question about iwlagn_rx_calib_result() Dan Carpenter
2011-12-07 9:07 ` Johannes Berg [this message]
2011-12-07 9:10 ` Johannes Berg
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=1323248833.3404.7.camel@jlt3.sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=dan.carpenter@oracle.com \
--cc=ilw@linux.intel.com \
--cc=linux-wireless@vger.kernel.org \
--cc=wey-yi.w.guy@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).