platform: msm_shared: check if cmdline is NULL before using it
Pointer 'final_cmdline' returned from call to function
'update_cmdline' may be NULL, will be passed to function
and may be dereferenced there by passing argument 2 to
function 'update_device_tree'.
Change-Id: I6cd52dd9b7799f0ecb3fc863497647ad653a5e9d
CRs-Fixed: 687723
diff --git a/platform/msm_shared/dev_tree.c b/platform/msm_shared/dev_tree.c
index 5df5a70..07c99ff 100644
--- a/platform/msm_shared/dev_tree.c
+++ b/platform/msm_shared/dev_tree.c
@@ -822,12 +822,15 @@
}
offset = ret;
- /* Adding the cmdline to the chosen node */
- ret = fdt_appendprop_string(fdt, offset, (const char*)"bootargs", (const void*)cmdline);
- if (ret)
+ if (cmdline)
{
- dprintf(CRITICAL, "ERROR: Cannot update chosen node [bootargs]\n");
- return ret;
+ /* Adding the cmdline to the chosen node */
+ ret = fdt_appendprop_string(fdt, offset, (const char*)"bootargs", (const void*)cmdline);
+ if (ret)
+ {
+ dprintf(CRITICAL, "ERROR: Cannot update chosen node [bootargs]\n");
+ return ret;
+ }
}
if (ramdisk_size) {