Skip to content

Commit

Permalink
pch_gbe: memory corruption calling pch_gbe_validate_option()
Browse files Browse the repository at this point in the history
pch_gbe_validate_option() modifies 32 bits of memory but we pass
&hw->phy.autoneg_advertised which only has 16 bits and &hw->mac.fc
which only has 8 bits.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Dan Carpenter authored and David S. Miller committed Mar 1, 2012
1 parent 1e804ae commit 73f98ea
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_param.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,10 @@ static void pch_gbe_check_copper_options(struct pch_gbe_adapter *adapter)
pr_debug("AutoNeg specified along with Speed or Duplex, AutoNeg parameter ignored\n");
hw->phy.autoneg_advertised = opt.def;
} else {
hw->phy.autoneg_advertised = AutoNeg;
pch_gbe_validate_option(
(int *)(&hw->phy.autoneg_advertised),
&opt, adapter);
int tmp = AutoNeg;

pch_gbe_validate_option(&tmp, &opt, adapter);
hw->phy.autoneg_advertised = tmp;
}
}

Expand Down Expand Up @@ -495,9 +495,10 @@ void pch_gbe_check_options(struct pch_gbe_adapter *adapter)
.arg = { .l = { .nr = (int)ARRAY_SIZE(fc_list),
.p = fc_list } }
};
hw->mac.fc = FlowControl;
pch_gbe_validate_option((int *)(&hw->mac.fc),
&opt, adapter);
int tmp = FlowControl;

pch_gbe_validate_option(&tmp, &opt, adapter);
hw->mac.fc = tmp;
}

pch_gbe_check_copper_options(adapter);
Expand Down

0 comments on commit 73f98ea

Please sign in to comment.