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

Commit a0b933e4 authored by Rajesh Bondugula's avatar Rajesh Bondugula
Browse files

msm: camera: sensor: Validate csid lane count



Validate the CSID lane count value received from userspace.
User will see an undefined behavior for camera if a value is 0
or greater than 4.

Crs-Fixed: 1110793
Signed-off-by: default avatarRajesh Bondugula <rajeshb@codeaurora.org>
Change-Id: If0253a6ee695c9d3d62b4b9882898a86eeee52a9
parent 2dc96b1c
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
/* Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2017, The Linux Foundation. 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
@@ -58,6 +58,7 @@
#define TRUE   1
#define FALSE  0

#define MAX_LANE_COUNT 4
#define CSID_TIMEOUT msecs_to_jiffies(100)

#undef CDBG
@@ -284,6 +285,12 @@ static int msm_csid_config(struct csid_device *csid_dev,
		csid_params->lane_assign);
	CDBG("%s csid_params phy_sel = %d\n", __func__,
		csid_params->phy_sel);
	if ((csid_params->lane_cnt == 0) ||
		(csid_params->lane_cnt > MAX_LANE_COUNT)) {
		pr_err("%s:%d invalid lane count = %d\n",
			__func__, __LINE__, csid_params->lane_cnt);
		return -EINVAL;
	}

	csid_dev->csid_lane_cnt = csid_params->lane_cnt;
	rc = msm_csid_reset(csid_dev);