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

Commit cf0e6416 authored by Trilokesh Rangam's avatar Trilokesh Rangam
Browse files

msm-camera: Validation of input parameter



The input array pointer cam_vreg and its associated length
num_vreg_seq is checked to avoid accessing the array if the
pointer is NULL and the associated length is non-zero. When
cam_vreg is NULL and num_vreg_seq is 0 the array does not
get accessed.

CRs-Fixed: 897259
Change-Id: I2f93955ec9a21c329290ead9706a7eeb1d640d3c
Signed-off-by: default avatarTrilokesh Rangam <tranga@codeaurora.org>
parent a3c6f163
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
/* Copyright (c) 2011-2014, The Linux Foundataion. All rights reserved.
/* Copyright (c) 2011-2014, 2017 The Linux Foundataion. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -394,9 +394,15 @@ int msm_camera_config_vreg(struct device *dev, struct camera_vreg_t *cam_vreg,
		pr_err("%s:%d vreg sequence invalid\n", __func__, __LINE__);
		return -EINVAL;
	}

	if (!num_vreg_seq)
		num_vreg_seq = num_vreg;

	if ((cam_vreg == NULL) && num_vreg_seq) {
		pr_err("%s:%d cam_vreg NULL\n", __func__, __LINE__);
		return -EINVAL;
	}

	if (config) {
		for (i = 0; i < num_vreg_seq; i++) {
			if (vreg_seq) {