Skip to contentSkip to conversation

misc: rtsx: Set setting_reg2 before use.

PATCH In review Tom Rix 5 participants 10 messages May 16, 2022 – May 19, 2022 Char and misc drivers

lore
Share & tools
lore

Tom Rix

author
#0 lore raw

PATCH 1/1 misc: rtsx: Set setting_reg2 before use.

The clang build fails with
rts5261.c:406:13: error: variable 'setting_reg2' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

        } else if (efuse_valid == 0) {
                   ^~~~~~~~~~~~~~~~

setting_reg2 is set in this block
if (efuse_valid == 2 || efuse_valid == 3) {
..

  } else if (efuse_valid == 0) {
    // default

..
}
But efuse_valid can also have a value of 1.
Change the 'else if' to 'else' to make the second block the default.

Fixes b1c5f3085149 ("misc: rtsx: add rts5261 efuse function")
---
 drivers/misc/cardreader/rts5261.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/cardreader/rts5261.c +1 -1
index 749cc5a46d13..f22634b14dc8 100644
@@ -403,7 +403,7 @@ static void rts5261_init_from_hw(struct rtsx_pcr *pcr)
 			setting_reg1 = PCR_SETTING_REG4;
 			setting_reg2 = PCR_SETTING_REG5;
 		}
-	} else if (efuse_valid == 0) {
+	} else {
 		// default
 		setting_reg1 = PCR_SETTING_REG1;
 		setting_reg2 = PCR_SETTING_REG2;
Signature · 1 line
2.27.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Tom Rix

The clang build fails with
rts5261.c:406:13: error: variable 'setting_reg2' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

        } else if (efuse_valid == 0) {
                   ^~~~~~~~~~~~~~~~

setting_reg2 is set in this block
if (efuse_valid == 2 || efuse_valid == 3) {
..

  } else if (efuse_valid == 0) {
    // default
Quoted 7 lines

..
}
But efuse_valid can also have a value of 1.
Change the 'else if' to 'else' to make the second block the default.

Fixes b1c5f3085149 ("misc: rtsx: add rts5261 efuse function")

I am not sure if this fix is correct from a functional standpoint (i.e. is treating efuse_valid == 1 the same as efuse_valid == 0 correct?) but it is better than not handling this value altogether. For what it's worth:

As a side note, it is unfortunate that this change made it into -next when there was an outstanding report about this warning:

https://lore.kernel.org/[email protected]/

Quoted 20 lines
---
 drivers/misc/cardreader/rts5261.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/cardreader/rts5261.c +1 -1
index 749cc5a46d13..f22634b14dc8 100644
@@ -403,7 +403,7 @@ static void rts5261_init_from_hw(struct rtsx_pcr *pcr)
 			setting_reg1 = PCR_SETTING_REG4;
 			setting_reg2 = PCR_SETTING_REG5;
 		}
-	} else if (efuse_valid == 0) {
+	} else {
 		// default
 		setting_reg1 = PCR_SETTING_REG1;
 		setting_reg2 = PCR_SETTING_REG2;
Signature · 1 line
2.27.0

Cheers,
Nathan

author
#2 lore raw
Quoted 16 lines · Nathan Chancellor
Quoted 15 lines · Tom Rix

The clang build fails with
rts5261.c:406:13: error: variable 'setting_reg2' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

         } else if (efuse_valid == 0) {
                    ^~~~~~~~~~~~~~~~

setting_reg2 is set in this block
if (efuse_valid == 2 || efuse_valid == 3) {
..

   } else if (efuse_valid == 0) {
     // default

..
}
But efuse_valid can also have a value of 1.
Change the 'else if' to 'else' to make the second block the default.

Quoted 6 lines
Quoted 2 lines
Fixes b1c5f3085149 ("misc: rtsx: add rts5261 efuse function")

I am not sure if this fix is correct from a functional standpoint (i.e. is treating efuse_valid == 1 the same as efuse_valid == 0 correct?) but it is better than not handling this value altogether. For what it's worth:

I looked at how the code used to work, this seemed better than initializing to NULL.

Quoted 5 lines

As a side note, it is unfortunate that this change made it into -next when there was an outstanding report about this warning:

From the clang side, this is a build break and my static analysis infra goes down.

These build breaks seem to happening every week, is there a precommit clang gating test that could be done for -next ?

Tom

Quoted 26 lines

https://lore.kernel.org/[email protected]/

Quoted 20 lines
---
  drivers/misc/cardreader/rts5261.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/cardreader/rts5261.c +1 -1
index 749cc5a46d13..f22634b14dc8 100644
@@ -403,7 +403,7 @@ static void rts5261_init_from_hw(struct rtsx_pcr *pcr)
  			setting_reg1 = PCR_SETTING_REG4;
  			setting_reg2 = PCR_SETTING_REG5;
  		}
-	} else if (efuse_valid == 0) {
+	} else {
  		// default
  		setting_reg1 = PCR_SETTING_REG1;
  		setting_reg2 = PCR_SETTING_REG2;
Signature · 1 line
2.27.0

Cheers,
Nathan

#3 lore raw
Quoted 32 lines · Tom Rix
Quoted 16 lines · Nathan Chancellor
Quoted 15 lines · Tom Rix

The clang build fails with
rts5261.c:406:13: error: variable 'setting_reg2' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

         } else if (efuse_valid == 0) {
                    ^~~~~~~~~~~~~~~~

setting_reg2 is set in this block
if (efuse_valid == 2 || efuse_valid == 3) {
..

   } else if (efuse_valid == 0) {
     // default

..
}
But efuse_valid can also have a value of 1.
Change the 'else if' to 'else' to make the second block the default.

Quoted 6 lines
Quoted 2 lines
Fixes b1c5f3085149 ("misc: rtsx: add rts5261 efuse function")

I am not sure if this fix is correct from a functional standpoint (i.e. is treating efuse_valid == 1 the same as efuse_valid == 0 correct?) but it is better than not handling this value altogether. For what it's worth:

I looked at how the code used to work, this seemed better than initializing to NULL.

Quoted 3 lines
Quoted 8 lines
Quoted 2 lines

As a side note, it is unfortunate that this change made it into -next when there was an outstanding report about this warning:

From the clang side, this is a build break and my static analysis infra
goes down.

These build breaks seem to happening every week, is there a precommit clang gating test that could be done for -next ?

Probably worth asking Stephen, though I don't think there's _any_ gating (i.e. presubmit testing) for -next, since that'd increase the build capacity needed. -next is tested post-merge (i.e. post submit testing) IIUC.

Quoted 30 lines

Tom

Quoted 26 lines

https://lore.kernel.org/[email protected]/

Quoted 18 lines
---
  drivers/misc/cardreader/rts5261.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/cardreader/rts5261.c +1 -2
index 749cc5a46d13..f22634b14dc8 100644
@@ -403,7 +403,7 @@ static void rts5261_init_from_hw(struct rtsx_pcr *pcr)
                     setting_reg1 = PCR_SETTING_REG4;
                     setting_reg2 = PCR_SETTING_REG5;
             }
-    } else if (efuse_valid == 0) {
+    } else {
             // default
             setting_reg1 = PCR_SETTING_REG1;
             setting_reg2 = PCR_SETTING_REG2;
--
Quoted 2 lines

2.27.0

Cheers,
Nathan

Signature · 2 lines
Thanks,
~Nick Desaulniers
#4 lore raw
Quoted 39 lines · Nick Desaulniers
Quoted 38 lines · Tom Rix
Quoted 16 lines · Nathan Chancellor
Quoted 15 lines · Tom Rix

The clang build fails with
rts5261.c:406:13: error: variable 'setting_reg2' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

         } else if (efuse_valid == 0) {
                    ^~~~~~~~~~~~~~~~

setting_reg2 is set in this block
if (efuse_valid == 2 || efuse_valid == 3) {
..

   } else if (efuse_valid == 0) {
     // default

..
}
But efuse_valid can also have a value of 1.
Change the 'else if' to 'else' to make the second block the default.

Quoted 6 lines
Quoted 2 lines
Fixes b1c5f3085149 ("misc: rtsx: add rts5261 efuse function")

I am not sure if this fix is correct from a functional standpoint (i.e. is treating efuse_valid == 1 the same as efuse_valid == 0 correct?) but it is better than not handling this value altogether. For what it's worth:

I looked at how the code used to work, this seemed better than initializing to NULL.

Quoted 5 lines

As a side note, it is unfortunate that this change made it into -next when there was an outstanding report about this warning:

From the clang side, this is a build break and my static analysis infra
goes down.

Quoted 7 lines
Quoted 2 lines

These build breaks seem to happening every week, is there a precommit clang gating test that could be done for -next ?

Probably worth asking Stephen, though I don't think there's _any_ gating (i.e. presubmit testing) for -next, since that'd increase the build capacity needed. -next is tested post-merge (i.e. post submit testing) IIUC.

Stephen does do build testing during the merges ("Between each merge, the tree was built with a ppc64_defconfig for powerpc, an allmodconfig for x86_64, a multi_v7_defconfig for arm and a native build of tools/perf"), in addition to testing after the final tree is done.

https://lore.kernel.org/[email protected]/

Increasing the "during merge" testing is not a reasonable request (IMO) due to the additional time it would add to the entire -next process. I am not sure that having Stephen do builds with clang post merge is any different from all the existing build coverage that we already have (the tree is already done at that point), other than maybe people listen to a human complaining more than a robot... :)

Cheers,
Nathan

#5 lore raw
In reply to Tom Rix
Quoted 21 lines · Tom Rix
Quoted 18 lines · Nathan Chancellor
Quoted 17 lines · Tom Rix

The clang build fails with
rts5261.c:406:13: error: variable 'setting_reg2' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

         } else if (efuse_valid == 0) {
                    ^~~~~~~~~~~~~~~~

setting_reg2 is set in this block
if (efuse_valid == 2 || efuse_valid == 3) {
..

   } else if (efuse_valid == 0) {
     // default

..
}
But efuse_valid can also have a value of 1.
Change the 'else if' to 'else' to make the second block the default.

Fixes b1c5f3085149 ("misc: rtsx: add rts5261 efuse function")
Quoted 7 lines
Quoted 4 lines

I am not sure if this fix is correct from a functional standpoint (i.e. is treating efuse_valid == 1 the same as efuse_valid == 0 correct?) but it is better than not handling this value altogether. For what it's worth:

I looked at how the code used to work, this seemed better than initializing to NULL.

Or maybe use a single if block?

u16 setting_reg1 =PCR_SETTING_REG1 , setting_reg2 = PCR_SETTING_REG2;
...

if ((efuse_valid == 2 || efuse_valid == 3) && (valid != 3) {
    setting_reg1 = PCR_SETTING_REG4;
    setting_reg2 = PCR_SETTING_REG5;
}

Kai-Heng

Quoted 42 lines
Quoted 6 lines

As a side note, it is unfortunate that this change made it into -next when there was an outstanding report about this warning:

From the clang side, this is a build break and my static analysis infra
goes down.

These build breaks seem to happening every week, is there a precommit clang gating test that could be done for -next ?

Tom

Quoted 26 lines

https://lore.kernel.org/[email protected]/

Quoted 18 lines
---
  drivers/misc/cardreader/rts5261.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/cardreader/rts5261.c +1 -2
index 749cc5a46d13..f22634b14dc8 100644
@@ -403,7 +403,7 @@ static void rts5261_init_from_hw(struct rtsx_pcr *pcr)
                     setting_reg1 = PCR_SETTING_REG4;
                     setting_reg2 = PCR_SETTING_REG5;
             }
-    } else if (efuse_valid == 0) {
+    } else {
             // default
             setting_reg1 = PCR_SETTING_REG1;
             setting_reg2 = PCR_SETTING_REG2;
--
Quoted 2 lines

2.27.0

Cheers,
Nathan

#6 lore raw
Quoted 73 lines

-----Original Message-----
From: Kai-Heng Feng <[email protected]>
Sent: Tuesday, May 17, 2022 9:53 AM
To: Tom Rix <[email protected]>
Cc: Nathan Chancellor <[email protected]>; [email protected]; [email protected]; [email protected]; Ricky WU <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] misc: rtsx: Set setting_reg2 before use.

Quoted 6 lines · Tom Rix
Quoted 3 lines · Nathan Chancellor
Quoted 2 lines · Tom Rix

The clang build fails with
rts5261.c:406:13: error: variable 'setting_reg2' is used uninitialized

whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
         } else if (efuse_valid == 0) {
                    ^~~~~~~~~~~~~~~~

setting_reg2 is set in this block
if (efuse_valid == 2 || efuse_valid == 3) { ..

   } else if (efuse_valid == 0) {
     // default

..
}
But efuse_valid can also have a value of 1.
Change the 'else if' to 'else' to make the second block the default.

Fixes b1c5f3085149 ("misc: rtsx: add rts5261 efuse function")
Quoted 8 lines
Quoted 5 lines

I am not sure if this fix is correct from a functional standpoint (i.e. is treating efuse_valid == 1 the same as efuse_valid == 0 correct?) but it is better than not handling this value altogether. For what it's
worth:

I looked at how the code used to work, this seemed better than initializing to NULL.

Or maybe use a single if block?

u16 setting_reg1 =PCR_SETTING_REG1 , setting_reg2 = PCR_SETTING_REG2; ...

if ((efuse_valid == 2 || efuse_valid == 3) && (valid != 3) {
    setting_reg1 = PCR_SETTING_REG4;
    setting_reg2 = PCR_SETTING_REG5;
}

Kai-Heng

Quoted 22 lines
Quoted 6 lines

As a side note, it is unfortunate that this change made it into -next when there was an outstanding report about this warning:

From the clang side, this is a build break and my static analysis
infra goes down.

These build breaks seem to happening every week, is there a precommit clang gating test that could be done for -next ?

Tom

Quoted 7 lines

https://lore.kernel.org/[email protected]/

Quoted 4 lines
---
  drivers/misc/cardreader/rts5261.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines

drivers/misc/cardreader/rts5261.c static void rts5261_init_from_hw(struct rtsx_pcr

Quoted 6 lines
drivers/misc/cardreader/rts5261.c +0 -0
index 749cc5a46d13..f22634b14dc8 100644
@@ -403,7 +403,7 @@ static void rts5261_init_from_hw(struct rtsx_pcr

*pcr)

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/misc/cardreader/rts5261.c +1 -1
                     setting_reg1 = PCR_SETTING_REG4;
                     setting_reg2 = PCR_SETTING_REG5;
             }
-    } else if (efuse_valid == 0) {
+    } else {
             // default
             setting_reg1 = PCR_SETTING_REG1;
             setting_reg2 = PCR_SETTING_REG2;

Sorry for the trouble
here can be changed to
...

} else if (efuse_valid == 0) {
		// default
		setting_reg1 = PCR_SETTING_REG1;
		setting_reg2 = PCR_SETTING_REG2;
} else {

return;
}
Because other values are invalid

Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

--
2.27.0

Cheers,
Nathan

------Please consider the environment before printing this e-mail.

#7 lore raw
Quoted 92 lines · Ricky WU
Quoted 73 lines

-----Original Message-----
From: Kai-Heng Feng <[email protected]>
Sent: Tuesday, May 17, 2022 9:53 AM
To: Tom Rix <[email protected]>
Cc: Nathan Chancellor <[email protected]>; [email protected]; [email protected]; [email protected]; Ricky WU <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] misc: rtsx: Set setting_reg2 before use.

Quoted 6 lines · Tom Rix
Quoted 3 lines · Nathan Chancellor
Quoted 2 lines · Tom Rix

The clang build fails with
rts5261.c:406:13: error: variable 'setting_reg2' is used uninitialized

whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
         } else if (efuse_valid == 0) {
                    ^~~~~~~~~~~~~~~~

setting_reg2 is set in this block
if (efuse_valid == 2 || efuse_valid == 3) { ..

   } else if (efuse_valid == 0) {
     // default

..
}
But efuse_valid can also have a value of 1.
Change the 'else if' to 'else' to make the second block the default.

Fixes b1c5f3085149 ("misc: rtsx: add rts5261 efuse function")
Quoted 8 lines
Quoted 5 lines

I am not sure if this fix is correct from a functional standpoint (i.e. is treating efuse_valid == 1 the same as efuse_valid == 0 correct?) but it is better than not handling this value altogether. For what it's
worth:

I looked at how the code used to work, this seemed better than initializing to NULL.

Or maybe use a single if block?

u16 setting_reg1 =PCR_SETTING_REG1 , setting_reg2 = PCR_SETTING_REG2; ...

if ((efuse_valid == 2 || efuse_valid == 3) && (valid != 3) {
    setting_reg1 = PCR_SETTING_REG4;
    setting_reg2 = PCR_SETTING_REG5;
}

Kai-Heng

Quoted 22 lines
Quoted 6 lines

As a side note, it is unfortunate that this change made it into -next when there was an outstanding report about this warning:

From the clang side, this is a build break and my static analysis
infra goes down.

These build breaks seem to happening every week, is there a precommit clang gating test that could be done for -next ?

Tom

Quoted 7 lines

https://lore.kernel.org/[email protected]/

Quoted 4 lines
---
  drivers/misc/cardreader/rts5261.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines

drivers/misc/cardreader/rts5261.c static void rts5261_init_from_hw(struct rtsx_pcr

Quoted 6 lines
drivers/misc/cardreader/rts5261.c +0 -0
index 749cc5a46d13..f22634b14dc8 100644
@@ -403,7 +403,7 @@ static void rts5261_init_from_hw(struct rtsx_pcr

*pcr)

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/misc/cardreader/rts5261.c +1 -1
                     setting_reg1 = PCR_SETTING_REG4;
                     setting_reg2 = PCR_SETTING_REG5;
             }
-    } else if (efuse_valid == 0) {
+    } else {
             // default
             setting_reg1 = PCR_SETTING_REG1;
             setting_reg2 = PCR_SETTING_REG2;

Sorry for the trouble
here can be changed to
...

Quoted 8 lines
} else if (efuse_valid == 0) {
		// default
		setting_reg1 = PCR_SETTING_REG1;
		setting_reg2 = PCR_SETTING_REG2;
} else {

return;
}
Because other values are invalid

Tom, were you going to send a v2 of this?

Cheers,
Nathan

author
#8 lore raw
Quoted 93 lines · Nathan Chancellor
Quoted 84 lines · Ricky WU
Quoted 66 lines

-----Original Message-----
From: Kai-Heng Feng <[email protected]>
Sent: Tuesday, May 17, 2022 9:53 AM
To: Tom Rix <[email protected]>
Cc: Nathan Chancellor <[email protected]>; [email protected]; [email protected]; [email protected]; Ricky WU <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] misc: rtsx: Set setting_reg2 before use.

Quoted 5 lines · Tom Rix
Quoted 3 lines · Nathan Chancellor
Quoted 2 lines · Tom Rix

The clang build fails with
rts5261.c:406:13: error: variable 'setting_reg2' is used uninitialized

whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
          } else if (efuse_valid == 0) {
                     ^~~~~~~~~~~~~~~~

setting_reg2 is set in this block

    if (efuse_valid == 2 || efuse_valid == 3) { ..
    } else if (efuse_valid == 0) {
      // default
..
    }

But efuse_valid can also have a value of 1.
Change the 'else if' to 'else' to make the second block the default.

Fixes b1c5f3085149 ("misc: rtsx: add rts5261 efuse function")
Quoted 7 lines
Quoted 5 lines

I am not sure if this fix is correct from a functional standpoint (i.e. is treating efuse_valid == 1 the same as efuse_valid == 0 correct?) but it is better than not handling this value altogether. For what it's
worth:

I looked at how the code used to work, this seemed better than initializing to NULL.

Or maybe use a single if block?

u16 setting_reg1 =PCR_SETTING_REG1 , setting_reg2 = PCR_SETTING_REG2; ...

if ((efuse_valid == 2 || efuse_valid == 3) && (valid != 3) {
     setting_reg1 = PCR_SETTING_REG4;
     setting_reg2 = PCR_SETTING_REG5;
}

Kai-Heng

Quoted 18 lines
Quoted 4 lines

As a side note, it is unfortunate that this change made it into -next when there was an outstanding report about this warning:

From the clang side, this is a build break and my static analysis
infra goes down.

These build breaks seem to happening every week, is there a precommit clang gating test that could be done for -next ?

Tom

Quoted 6 lines

https://lore.kernel.org/[email protected]/

Quoted 4 lines
---
   drivers/misc/cardreader/rts5261.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines

drivers/misc/cardreader/rts5261.c static void rts5261_init_from_hw(struct rtsx_pcr

Quoted 6 lines
drivers/misc/cardreader/rts5261.c +0 -0
index 749cc5a46d13..f22634b14dc8 100644
@@ -403,7 +403,7 @@ static void rts5261_init_from_hw(struct rtsx_pcr

*pcr)

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/misc/cardreader/rts5261.c +1 -1
                      setting_reg1 = PCR_SETTING_REG4;
                      setting_reg2 = PCR_SETTING_REG5;
              }
-    } else if (efuse_valid == 0) {
+    } else {
              // default
              setting_reg1 = PCR_SETTING_REG1;
              setting_reg2 = PCR_SETTING_REG2;

Sorry for the trouble
here can be changed to
...

Quoted 8 lines
} else if (efuse_valid == 0) {
		// default
		setting_reg1 = PCR_SETTING_REG1;
		setting_reg2 = PCR_SETTING_REG2;
} else {

return;
}
Because other values are invalid

Quoted 1 line

Tom, were you going to send a v2 of this?

No.

Miquèl has the best fix.

https://lore.kernel.org/lkml/20220518170920.4db16990@xps-13/

Tom

Quoted 4 lines

Cheers,
Nathan

#9 lore raw
Quoted 95 lines · Tom Rix
Quoted 93 lines · Nathan Chancellor
Quoted 92 lines · Ricky WU
Quoted 66 lines

-----Original Message-----
From: Kai-Heng Feng <[email protected]>
Sent: Tuesday, May 17, 2022 9:53 AM
To: Tom Rix <[email protected]>
Cc: Nathan Chancellor <[email protected]>; [email protected]; [email protected]; [email protected]; Ricky WU <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] misc: rtsx: Set setting_reg2 before use.

Quoted 5 lines · Tom Rix
Quoted 3 lines · Nathan Chancellor
Quoted 2 lines · Tom Rix

The clang build fails with
rts5261.c:406:13: error: variable 'setting_reg2' is used uninitialized

whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
          } else if (efuse_valid == 0) {
                     ^~~~~~~~~~~~~~~~

setting_reg2 is set in this block

    if (efuse_valid == 2 || efuse_valid == 3) { ..
    } else if (efuse_valid == 0) {
      // default
..
    }

But efuse_valid can also have a value of 1.
Change the 'else if' to 'else' to make the second block the default.

Fixes b1c5f3085149 ("misc: rtsx: add rts5261 efuse function")
Quoted 7 lines
Quoted 5 lines

I am not sure if this fix is correct from a functional standpoint (i.e. is treating efuse_valid == 1 the same as efuse_valid == 0 correct?) but it is better than not handling this value altogether. For what it's
worth:

I looked at how the code used to work, this seemed better than initializing to NULL.

Or maybe use a single if block?

u16 setting_reg1 =PCR_SETTING_REG1 , setting_reg2 = PCR_SETTING_REG2; ...

if ((efuse_valid == 2 || efuse_valid == 3) && (valid != 3) {
     setting_reg1 = PCR_SETTING_REG4;
     setting_reg2 = PCR_SETTING_REG5;
}

Kai-Heng

Quoted 18 lines
Quoted 4 lines

As a side note, it is unfortunate that this change made it into -next when there was an outstanding report about this warning:

From the clang side, this is a build break and my static analysis
infra goes down.

These build breaks seem to happening every week, is there a precommit clang gating test that could be done for -next ?

Tom

Quoted 6 lines

https://lore.kernel.org/[email protected]/

Quoted 4 lines
---
   drivers/misc/cardreader/rts5261.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines

drivers/misc/cardreader/rts5261.c static void rts5261_init_from_hw(struct rtsx_pcr

Quoted 6 lines
drivers/misc/cardreader/rts5261.c +0 -0
index 749cc5a46d13..f22634b14dc8 100644
@@ -403,7 +403,7 @@ static void rts5261_init_from_hw(struct rtsx_pcr

*pcr)

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/misc/cardreader/rts5261.c +1 -1
                      setting_reg1 = PCR_SETTING_REG4;
                      setting_reg2 = PCR_SETTING_REG5;
              }
-    } else if (efuse_valid == 0) {
+    } else {
              // default
              setting_reg1 = PCR_SETTING_REG1;
              setting_reg2 = PCR_SETTING_REG2;

Sorry for the trouble
here can be changed to
...

} else if (efuse_valid == 0) {
		// default
		setting_reg1 = PCR_SETTING_REG1;
		setting_reg2 = PCR_SETTING_REG2;
} else {

return;
}
Because other values are invalid

Quoted 7 lines
Quoted 1 line

Tom, were you going to send a v2 of this?

No.

Miquèl has the best fix.

https://lore.kernel.org/lkml/20220518170920.4db16990@xps-13/

Different warning/patch I think? There are too many of these flying around as of late :( this one doesn't have a new version from what I can tell.

I do see a fix for that one available:

https://lore.kernel.org/[email protected]/

Cheers,
Nathan