public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] mach-snapdragon: Fix overwriting last digit of serial number
@ 2020-03-16 16:51 Jan-Christoph Tebbe
  2020-03-20 17:31 ` Tom Rini
  2020-04-05 23:04 ` Tom Rini
  0 siblings, 2 replies; 4+ messages in thread
From: Jan-Christoph Tebbe @ 2020-03-16 16:51 UTC (permalink / raw)
  To: u-boot

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@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;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] mach-snapdragon: Fix overwriting last digit of serial number
  2020-03-16 16:51 [PATCH] mach-snapdragon: Fix overwriting last digit of serial number Jan-Christoph Tebbe
@ 2020-03-20 17:31 ` Tom Rini
  2020-04-01 10:18   ` Jan-Christoph Tebbe
  2020-04-05 23:04 ` Tom Rini
  1 sibling, 1 reply; 4+ messages in thread
From: Tom Rini @ 2020-03-20 17:31 UTC (permalink / raw)
  To: u-boot

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@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!

-- 
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] mach-snapdragon: Fix overwriting last digit of serial number
  2020-03-20 17:31 ` Tom Rini
@ 2020-04-01 10:18   ` Jan-Christoph Tebbe
  0 siblings, 0 replies; 4+ messages in thread
From: Jan-Christoph Tebbe @ 2020-04-01 10:18 UTC (permalink / raw)
  To: u-boot

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 <trini@konsulko.com>:
>
> 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@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!
>
> --
> Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] mach-snapdragon: Fix overwriting last digit of serial number
  2020-03-16 16:51 [PATCH] mach-snapdragon: Fix overwriting last digit of serial number Jan-Christoph Tebbe
  2020-03-20 17:31 ` Tom Rini
@ 2020-04-05 23:04 ` Tom Rini
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Rini @ 2020-04-05 23:04 UTC (permalink / raw)
  To: u-boot

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@ithinx.io>

Applied to u-boot/master, thanks!

-- 
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-05 23:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-16 16:51 [PATCH] mach-snapdragon: Fix overwriting last digit of serial number Jan-Christoph Tebbe
2020-03-20 17:31 ` Tom Rini
2020-04-01 10:18   ` Jan-Christoph Tebbe
2020-04-05 23:04 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox