mach-snapdragon: Fix overwriting last digit of serial number
Subsystems (2)
PATCH 1/1 mach-snapdragon: Fix overwriting last digit of serial number
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.
--- arch/arm/mach-snapdragon/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-snapdragon/misc.c +1 -1
@@ -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 ;
Signature · 1 line
2.17.1
PATCH 1/1 mach-snapdragon: Fix overwriting last digit of serial number
Quoted 15 lines · Jan-Christoph Tebbe
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 <[email protected]>--- arch/arm/mach-snapdragon/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/mach-snapdragon/misc.c +0
-0
arch/arm/mach-snapdragon/misc.c void msm_generate_mac_addr(u8 *mac) · line 47
Quoted 8 lines
arch/arm/mach-snapdragon/misc.c +1
-1@@ -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!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200320/5b24283c/attachment.sig>
PATCH 1/1 mach-snapdragon: Fix overwriting last digit of serial number
Hello Tom,
the buffer has to hold 8 hex digits and a trailing \0, therefore 9 bytes should be enough. The problem was, that snprintf was told sn were only 8 characters long, making snprintf to only write 7 digits followed by the trailing \0.
Jan-Christoph
Am Fr., 20. M?rz 2020 um 18:31 Uhr schrieb Tom Rini <[email protected]>:
Quoted 32 lines · Jan-Christoph Tebbe
Quoted 16 lines
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 <[email protected]>--- arch/arm/mach-snapdragon/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/mach-snapdragon/misc.c +0
-0arch/arm/mach-snapdragon/misc.c void msm_generate_mac_addr(u8 *mac) · line 47
Quoted 8 lines
arch/arm/mach-snapdragon/misc.c +1
-1@@ -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!
--
Tom
PATCH 1/1 mach-snapdragon: Fix overwriting last digit of serial number
In reply to Jan-Christoph TebbeQuoted 6 lines · Jan-Christoph Tebbe
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 <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200405/d1578cd3/attachment.sig>