Skip to content

Commit 349fa27

Browse files
HoratiuVulturkuba-moo
authored andcommitted
net: sparx5: Fix initialization of variables on stack
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2bc0a83 commit 349fa27

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static u64 sparx5_ptp_get_1ppm(struct sparx5 *sparx5)
3232
* (1/1000000)/((2^-59)/X)
3333
*/
3434

35-
u64 res;
35+
u64 res = 0;
3636

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

5555
static u64 sparx5_ptp_get_nominal_value(struct sparx5 *sparx5)
5656
{
57-
u64 res;
57+
u64 res = 0;
5858

5959
switch (sparx5->coreclock) {
6060
case SPX5_CORE_CLOCK_250MHZ:

0 commit comments

Comments
 (0)