msm: camera: core : Validate the dev name during the node ioctl handler

Validate the context device name with node name. If device name is
not matching return the error.

Change-Id: I8dee4e6f64e17b0d1e486077a2c8b0df562a702e
Signed-off-by: Rishabh Jain <risjai@codeaurora.org>
This commit is contained in:
Jigarkumar Zala
2019-06-11 11:31:11 -07:00
committed by Gerrit - the friendly Code Review server
parent 396a4cc576
commit 40047f58df
19 changed files with 83 additions and 23 deletions

View File

@@ -25,6 +25,7 @@
#include "cam_sensor_util.h"
#include "cam_soc_util.h"
#include "cam_debug_util.h"
#include "cam_context.h"
#define NUM_MASTERS 2
#define NUM_QUEUES 2
@@ -83,6 +84,7 @@ struct intf_params {
/**
* struct cam_actuator_ctrl_t
* @device_name: Device name
* @i2c_driver: I2C device info
* @pdev: Platform device
* @cci_i2c_master: I2C structure
@@ -98,10 +100,10 @@ struct intf_params {
* @i2c_data: I2C register settings structure
* @act_info: Sensor query cap structure
* @of_node: Node ptr
* @device_name: Device name
* @last_flush_req: Last request to flush
*/
struct cam_actuator_ctrl_t {
char device_name[CAM_CTX_DEV_NAME_MAX_LENGTH];
struct i2c_driver *i2c_driver;
enum cci_i2c_master_t cci_i2c_master;
enum cci_device_num cci_num;
@@ -116,7 +118,6 @@ struct cam_actuator_ctrl_t {
struct i2c_data_settings i2c_data;
struct cam_actuator_query_cap act_info;
struct intf_params bridge_intf;
char device_name[20];
uint32_t last_flush_req;
};

View File

@@ -8,5 +8,6 @@ ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_u
ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_cci
ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr
ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/
ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core
obj-$(CONFIG_SPECTRA_CAMERA) += cam_csiphy_soc.o cam_csiphy_dev.o cam_csiphy_core.o

View File

@@ -26,6 +26,7 @@
#include <cam_cpas_api.h>
#include "cam_soc_util.h"
#include "cam_debug_util.h"
#include "cam_context.h"
#define MAX_CSIPHY 6
#define MAX_DPHY_DATA_LN 4
@@ -235,6 +236,7 @@ struct cam_csiphy_param {
/**
* struct csiphy_device
* @device_name: Device name
* @pdev: Platform device
* @irq: Interrupt structure
* @base: Base address
@@ -263,6 +265,7 @@ struct cam_csiphy_param {
* @csiphy_cpas_cp_reg_mask: CP reg mask for phy instance
*/
struct csiphy_device {
char device_name[CAM_CTX_DEV_NAME_MAX_LENGTH];
struct mutex mutex;
uint32_t hw_version;
enum cam_csiphy_state csiphy_state;
@@ -282,7 +285,6 @@ struct csiphy_device {
uint32_t clk_lane;
uint32_t acquire_count;
uint32_t start_dev_count;
char device_name[20];
uint32_t is_acquired_dev_combo_mode;
struct cam_hw_soc_info soc_info;
uint32_t cpas_handle;

View File

@@ -8,4 +8,6 @@ ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_u
ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr
ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_cci
ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/
ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core
obj-$(CONFIG_SPECTRA_CAMERA) += cam_eeprom_dev.o cam_eeprom_core.o cam_eeprom_soc.o

View File

@@ -22,6 +22,7 @@
#include <cam_subdev.h>
#include <cam_sensor.h>
#include "cam_soc_util.h"
#include "cam_context.h"
#define DEFINE_MSM_MUTEX(mutexname) \
static struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)
@@ -152,6 +153,7 @@ struct eebin_info {
/**
* struct cam_eeprom_ctrl_t - EEPROM control structure
* @device_name : Device name
* @pdev : platform device
* @spi : spi device
* @eeprom_mutex : eeprom mutex
@@ -170,6 +172,7 @@ struct eebin_info {
* @eebin_info : EEBIN address, size info
*/
struct cam_eeprom_ctrl_t {
char device_name[CAM_CTX_DEV_NAME_MAX_LENGTH];
struct platform_device *pdev;
struct spi_device *spi;
struct mutex eeprom_mutex;
@@ -184,7 +187,6 @@ struct cam_eeprom_ctrl_t {
enum cam_eeprom_state cam_eeprom_state;
bool userspace_probe;
struct cam_eeprom_memory_block_t cal_data;
char device_name[20];
uint16_t is_multimodule_mode;
struct i2c_settings_array wr_settings;
struct eebin_info eebin_info;

View File

@@ -379,6 +379,8 @@ static int cam_flash_init_subdev(struct cam_flash_ctrl *fctrl)
{
int rc = 0;
strlcpy(fctrl->device_name, CAM_FLASH_NAME,
sizeof(fctrl->device_name));
fctrl->v4l2_dev_str.internal_ops =
&cam_flash_internal_ops;
fctrl->v4l2_dev_str.ops = &cam_flash_subdev_ops;

View File

@@ -28,6 +28,7 @@
#include "cam_debug_util.h"
#include "cam_sensor_io.h"
#include "cam_flash_core.h"
#include "cam_context.h"
#define CAMX_FLASH_DEV_NAME "cam-flash-dev"
@@ -153,6 +154,7 @@ struct cam_flash_func_tbl {
/**
* struct cam_flash_ctrl
* @device_name : Device name
* @soc_info : Soc related information
* @pdev : Platform device
* @per_frame[] : Per_frame setting array
@@ -179,6 +181,7 @@ struct cam_flash_func_tbl {
* @last_flush_req : last request to flush
*/
struct cam_flash_ctrl {
char device_name[CAM_CTX_DEV_NAME_MAX_LENGTH];
struct cam_hw_soc_info soc_info;
struct platform_device *pdev;
struct cam_sensor_power_ctrl_t power_info;

View File

@@ -8,5 +8,6 @@ ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_res_mgr
ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils
ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr
ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_cci
ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core/
obj-$(CONFIG_SPECTRA_CAMERA) += cam_ois_dev.o cam_ois_core.o cam_ois_soc.o

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
*/
#ifndef _CAM_OIS_DEV_H_
#define _CAM_OIS_DEV_H_
@@ -20,6 +20,7 @@
#include <cam_mem_mgr.h>
#include <cam_subdev.h>
#include "cam_soc_util.h"
#include "cam_context.h"
#define DEFINE_MSM_MUTEX(mutexname) \
static struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)
@@ -83,6 +84,7 @@ struct cam_ois_intf_params {
/**
* struct cam_ois_ctrl_t - OIS ctrl private data
* @device_name : ois device_name
* @pdev : platform device
* @ois_mutex : ois mutex
* @soc_info : ois soc related info
@@ -95,7 +97,6 @@ struct cam_ois_intf_params {
* @i2c_calib_data : ois i2c calib settings
* @ois_device_type : ois device type
* @cam_ois_state : ois_device_state
* @ois_name : ois name
* @ois_fw_flag : flag for firmware download
* @is_ois_calib : flag for Calibration data
* @opcode : ois opcode
@@ -103,6 +104,7 @@ struct cam_ois_intf_params {
*
*/
struct cam_ois_ctrl_t {
char device_name[CAM_CTX_DEV_NAME_MAX_LENGTH];
struct platform_device *pdev;
struct mutex ois_mutex;
struct cam_hw_soc_info soc_info;
@@ -116,7 +118,6 @@ struct cam_ois_ctrl_t {
struct i2c_settings_array i2c_mode_data;
enum msm_camera_device_type_t ois_device_type;
enum cam_ois_state cam_ois_state;
char device_name[20];
char ois_name[32];
uint8_t ois_fw_flag;
uint8_t is_ois_calib;

View File

@@ -23,6 +23,7 @@
#include <cam_subdev.h>
#include <cam_sensor_io.h>
#include "cam_debug_util.h"
#include "cam_context.h"
#define NUM_MASTERS 2
#define NUM_QUEUES 2
@@ -65,6 +66,7 @@ struct intf_params {
/**
* struct cam_sensor_ctrl_t: Camera control structure
* @device_name: Sensor device name
* @pdev: Platform device
* @cam_sensor_mutex: Sensor mutex
* @sensordata: Sensor board Information
@@ -80,7 +82,6 @@ struct intf_params {
* @i2c_data: Sensor I2C register settings
* @sensor_info: Sensor query cap structure
* @bridge_intf: Bridge interface structure
* @device_name: Sensor device structure
* @streamon_count: Count to hold the number of times stream on called
* @streamoff_count: Count to hold the number of times stream off called
* @bob_reg_index: Hold to BoB regulator index
@@ -89,6 +90,7 @@ struct intf_params {
* @pipeline_delay: Sensor pipeline delay
*/
struct cam_sensor_ctrl_t {
char device_name[CAM_CTX_DEV_NAME_MAX_LENGTH];
struct platform_device *pdev;
struct cam_hw_soc_info soc_info;
struct mutex cam_sensor_mutex;
@@ -106,7 +108,6 @@ struct cam_sensor_ctrl_t {
struct i2c_data_settings i2c_data;
struct cam_sensor_query_cap sensor_info;
struct intf_params bridge_intf;
char device_name[20];
uint32_t streamon_count;
uint32_t streamoff_count;
int bob_reg_index;