Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 27ed2467 authored by Maria Yu's avatar Maria Yu
Browse files

msm: camera: Add error check for msm_sd_register fail



This patch fixes a system crash by adding a proper error
handling in case msm_sd_register() has failed.

Without this new error handling, the caller will try to
access s_init->msm_sd.sd.devnode while it is null, which
leads to a crash.

Change-Id: I22009a1e5c8b6e12ff47106b0227e13ff046d86c
Signed-off-by: default avatarMaria Yu <aiquny@codeaurora.org>
parent 928de4b5
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@ static long msm_sensor_init_subdev_fops_ioctl(

static int __init msm_sensor_init_module(void)
{
	int ret = 0;
	/* Allocate memory for msm_sensor_init control structure */
	s_init = kzalloc(sizeof(struct msm_sensor_init_t), GFP_KERNEL);
	if (!s_init) {
@@ -184,7 +185,11 @@ static int __init msm_sensor_init_module(void)
	s_init->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_SENSOR_INIT;
	s_init->msm_sd.sd.entity.name = s_init->msm_sd.sd.name;
	s_init->msm_sd.close_seq = MSM_SD_CLOSE_2ND_CATEGORY | 0x6;
	msm_sd_register(&s_init->msm_sd);
	ret = msm_sd_register(&s_init->msm_sd);
	if (ret) {
		CDBG("%s: msm_sd_register error = %d\n", __func__, rc);
		goto error;
	}

	msm_sensor_init_v4l2_subdev_fops = v4l2_subdev_fops;
#ifdef CONFIG_COMPAT
@@ -197,6 +202,10 @@ static int __init msm_sensor_init_module(void)
	init_waitqueue_head(&s_init->state_wait);

	return 0;
error:
	mutex_destroy(&s_init->imutex);
	kfree(s_init);
	return ret;
}

static void __exit msm_sensor_exit_module(void)