diff mbox series

mach-snapdragon: Fix overwriting last digit of serial number

Message ID CAOn6aLKf4c3==Sm_cx1Ch602pMer97_2rBet9uY2YUQXvSqcWg@mail.gmail.com
State Accepted
Commit 740370282e0caa9fab1c5865fe9b9a58ac008c5f
Headers show
Series mach-snapdragon: Fix overwriting last digit of serial number | expand

Commit Message

Jan-Christoph Tebbe March 16, 2020, 4:51 p.m. UTC
When generating the MAC address based on the boards serial number
the last digit was overwritten with the null termination. That way
boards with serial numbers close to each other would use the same
MAC address.

Signed-off-by: Jan-Christoph Tebbe <Jan-Christoph.Tebbe at ithinx.io>
---
 arch/arm/mach-snapdragon/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tom Rini March 20, 2020, 5:31 p.m. UTC | #1
On Mon, Mar 16, 2020 at 05:51:51PM +0100, Jan-Christoph Tebbe wrote:

> When generating the MAC address based on the boards serial number
> the last digit was overwritten with the null termination. That way
> boards with serial numbers close to each other would use the same
> MAC address.
> 
> Signed-off-by: Jan-Christoph Tebbe <Jan-Christoph.Tebbe at ithinx.io>
> ---
>  arch/arm/mach-snapdragon/misc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-snapdragon/misc.c b/arch/arm/mach-snapdragon/misc.c
> index f6c87866c0..aaa561c2c6 100644
> --- a/arch/arm/mach-snapdragon/misc.c
> +++ b/arch/arm/mach-snapdragon/misc.c
> @@ -41,7 +41,7 @@ void msm_generate_mac_addr(u8 *mac)
>   int i;
>   char sn[9];
> 
> - snprintf(sn, 8, "%08x", msm_board_serial());
> + snprintf(sn, 9, "%08x", msm_board_serial());
> 
>   /* fill in the mac with serialno, use locally adminstrated pool */
>   mac[0] = 0x02;

OK, so sn is size 9 and now you're filling the whole thing.  Why don't
we need to increase sn to size 10?  Am I missing something?  Thanks!
diff mbox series

Patch

diff --git a/arch/arm/mach-snapdragon/misc.c b/arch/arm/mach-snapdragon/misc.c
index f6c87866c0..aaa561c2c6 100644
--- a/arch/arm/mach-snapdragon/misc.c
+++ b/arch/arm/mach-snapdragon/misc.c
@@ -41,7 +41,7 @@  void msm_generate_mac_addr(u8 *mac)
  int i;
  char sn[9];

- snprintf(sn, 8, "%08x", msm_board_serial());
+ snprintf(sn, 9, "%08x", msm_board_serial());

  /* fill in the mac with serialno, use locally adminstrated pool */
  mac[0] = 0x02;