Skip to content

Commit

Permalink
net: sparx5: Fix initialization of variables on stack
Browse files Browse the repository at this point in the history
The variables 'res' inside the functions sparx5_ptp_get_1ppm and
sparx5_ptp_get_nominal_value was not initialized. So in case of the default
case of the switch after, it would return an uninitialized variable.
This makes also the clang builds to failed.

Fixes: 0933bd0 ("net: sparx5: Add support for ptp clocks")
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Link: https://lore.kernel.org/r/20220304140918.3356873-1-horatiu.vultur@microchip.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Horatiu Vultur authored and Jakub Kicinski committed Mar 5, 2022
1 parent 2bc0a83 commit 349fa27
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static u64 sparx5_ptp_get_1ppm(struct sparx5 *sparx5)
* (1/1000000)/((2^-59)/X)
*/

u64 res;
u64 res = 0;

switch (sparx5->coreclock) {
case SPX5_CORE_CLOCK_250MHZ:
Expand All @@ -54,7 +54,7 @@ static u64 sparx5_ptp_get_1ppm(struct sparx5 *sparx5)

static u64 sparx5_ptp_get_nominal_value(struct sparx5 *sparx5)
{
u64 res;
u64 res = 0;

switch (sparx5->coreclock) {
case SPX5_CORE_CLOCK_250MHZ:
Expand Down

0 comments on commit 349fa27

Please sign in to comment.