From: Petr Hodina <[email protected]>

Check the android command line if it contain the 'androidboot.serialno'
so the qcom_set_serialno() either the return value or skips the value.

Fix also the helper to parse the value as the last word of the command
line.

Signed-off-by: Petr Hodina <[email protected]>
---
The serial number is currently broken on devices where the command line
has no androidboot.serialno or passes it as the last word.

Fix it so it does not set the value from uninitialised stack data.
---
 arch/arm/mach-snapdragon/board.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c
index 5fb3240acc5..50edcd0f6ce 100644
--- a/arch/arm/mach-snapdragon/board.c
+++ b/arch/arm/mach-snapdragon/board.c
@@ -331,15 +331,13 @@ static int get_cmdline_option(const char *cmdline, const 
char *key, char *out, i
                return -ENOENT;
 
        p += strlen(key);
-       p_end = strstr(p, " ");
-       if (!p_end)
-               return -ENOENT;
 
-       len = p_end - p;
-       if (len > out_len)
-               len = out_len;
+       p_end = strchr(p, ' ');
+       len = p_end ? p_end - p : strlen(p);
+       if (len >= out_len)
+               len = out_len - 1;
 
-       strncpy(out, p, len);
+       memcpy(out, p, len);
        out[len] = '\0';
 
        return 0;
@@ -373,7 +371,9 @@ void qcom_set_serialno(void)
                return;
        }
 
-       get_cmdline_option(cmdline, "androidboot.serialno=", serial, 
sizeof(serial));
+       if (get_cmdline_option(cmdline, "androidboot.serialno=", serial, 
sizeof(serial)))
+               return;
+
        if (serial[0] != '\0')
                env_set("serial#", serial);
 }

---
base-commit: 1bcb2fe324180d0a8cfbdb0511737eba1d5b8550
change-id: 20261016-b4-snapdragon-serialno-ae7e5327b573

Best regards,
--  
Petr Hodina <[email protected]>


Reply via email to