Skip to content

Commit

Permalink
net/netvsc: fix sizeof calculation
Browse files Browse the repository at this point in the history
[ upstream commit 86fb73f5bf401afc9d52144f27e6d1cf4f64348b ]

Found by cppcheck.

drivers/net/netvsc/hn_rndis.c:332:21: warning:
 Found calculation inside sizeof().
 [sizeofCalculation]  if (len < sizeof(3 * sizeof(uint32_t))) {

Fixes: 4e9c73e ("net/netvsc: add Hyper-V network device")

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Long Li <longli@microsoft.com>
  • Loading branch information
shemminger authored and kevintraynor committed Jul 18, 2023
1 parent 086b984 commit 0df6ac4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/netvsc/hn_rndis.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ void hn_rndis_receive_response(struct hn_data *hv,

hn_rndis_dump(data);

if (len < sizeof(3 * sizeof(uint32_t))) {
/* Check we can read first three data fields from RNDIS header */
if (len < 3 * sizeof(uint32_t)) {
PMD_DRV_LOG(ERR,
"missing RNDIS header %u", len);
return;
Expand Down

0 comments on commit 0df6ac4

Please sign in to comment.