From: Evgeny Voevodin Date: Wed, 17 Oct 2012 04:11:35 +0000 (+0400) Subject: vl.c: Move webcam parsing after kernel_cmdline initialization X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1405^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=443ab89dccbe10c81afeaa9647a40b8280efb4db;p=sdk%2Femulator%2Fqemu.git vl.c: Move webcam parsing after kernel_cmdline initialization Before this commit the code in webcam parsing: gchar *tmp_cam_kcmd = kernel_cmdline; kernel_cmdline = g_strdup_printf("%s enable_cam=%d", tmp_cam_kcmd, is_webcam_enabled); could cause a segmentation fault because kernel_cmdline was not initialized yet. Signed-off-by: Evgeny Voevodin --- diff --git a/vl.c b/vl.c index d622b27ee5..69456cd560 100644 --- a/vl.c +++ b/vl.c @@ -3527,30 +3527,6 @@ int main(int argc, char **argv, char **envp) #endif #endif -#if defined(CONFIG_MARU) && (!defined(CONFIG_DARWIN)) - is_webcam_enabled = marucam_device_check(WEBCAM_INFO_WRITE); - if (!is_webcam_enabled) { - fprintf (stderr, "[Webcam] Webcam support was disabled " - "due to the fail of webcam capability check!\n"); - } - - gchar *tmp_cam_kcmd = kernel_cmdline; - kernel_cmdline = g_strdup_printf("%s enable_cam=%d", tmp_cam_kcmd, is_webcam_enabled); - g_free(tmp_cam_kcmd); - - if (is_webcam_enabled) { - device_opt_finding_t devp = {MARUCAM_DEV_NAME, 0}; - qemu_opts_foreach(qemu_find_opts("device"), find_device_opt, &devp, 0); - if (devp.found == 0) { - if (!qemu_opts_parse(qemu_find_opts("device"), MARUCAM_DEV_NAME, 1)) { - fprintf(stderr, "Failed to initialize the marucam device.\n"); - exit(1); - } - } - fprintf(stdout, "[Webcam] Webcam support was enabled.\n"); - } -#endif - /* Open the logfile at this point, if necessary. We can't open the logfile * when encountering either of the logging options (-d or -D) because the * other one may be encountered later on the command line, changing the @@ -3699,6 +3675,30 @@ int main(int argc, char **argv, char **envp) kernel_cmdline = ""; } +#if defined(CONFIG_MARU) && (!defined(CONFIG_DARWIN)) + is_webcam_enabled = marucam_device_check(WEBCAM_INFO_WRITE); + if (!is_webcam_enabled) { + fprintf (stderr, "[Webcam] Webcam support was disabled " + "due to the fail of webcam capability check!\n"); + } + + gchar *tmp_cam_kcmd = kernel_cmdline; + kernel_cmdline = g_strdup_printf("%s enable_cam=%d", tmp_cam_kcmd, is_webcam_enabled); + g_free(tmp_cam_kcmd); + + if (is_webcam_enabled) { + device_opt_finding_t devp = {MARUCAM_DEV_NAME, 0}; + qemu_opts_foreach(qemu_find_opts("device"), find_device_opt, &devp, 0); + if (devp.found == 0) { + if (!qemu_opts_parse(qemu_find_opts("device"), MARUCAM_DEV_NAME, 1)) { + fprintf(stderr, "Failed to initialize the marucam device.\n"); + exit(1); + } + } + fprintf(stdout, "[Webcam] Webcam support was enabled.\n"); + } +#endif + linux_boot = (kernel_filename != NULL); if (!linux_boot && *kernel_cmdline != '\0') {