msm: camera: sensor: TOCTOU error handling
- Change to dereference s_ctrl only after proper NULL Dereference Check. CRs-Fixed: 3875406 Change-Id: I8e2c717b22efff2a7d6503d38c048e30eff230da Signed-off-by: Swami Reddy Reddy <quic_swamired@quicinc.com>
This commit is contained in:
committed by
Michael Bestas
parent
c22009ad76
commit
423f14b6e6
@@ -656,13 +656,14 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
|
||||
{
|
||||
int rc = 0, pkt_opcode = 0;
|
||||
struct cam_control *cmd = (struct cam_control *)arg;
|
||||
struct cam_sensor_power_ctrl_t *power_info =
|
||||
&s_ctrl->sensordata->power_info;
|
||||
struct cam_sensor_power_ctrl_t *power_info = NULL;
|
||||
if (!s_ctrl || !arg) {
|
||||
CAM_ERR(CAM_SENSOR, "s_ctrl is NULL");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
power_info = &s_ctrl->sensordata->power_info;
|
||||
|
||||
if (cmd->op_code != CAM_SENSOR_PROBE_CMD) {
|
||||
if (cmd->handle_type != CAM_HANDLE_USER_POINTER) {
|
||||
CAM_ERR(CAM_SENSOR, "Invalid handle type: %d",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Copyright (c) 2022-2024, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
@@ -785,13 +785,14 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
|
||||
{
|
||||
int rc = 0, pkt_opcode = 0;
|
||||
struct cam_control *cmd = (struct cam_control *)arg;
|
||||
struct cam_sensor_power_ctrl_t *power_info =
|
||||
&s_ctrl->sensordata->power_info;
|
||||
struct cam_sensor_power_ctrl_t *power_info = NULL;
|
||||
if (!s_ctrl || !arg) {
|
||||
CAM_ERR(CAM_SENSOR, "s_ctrl is NULL");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
power_info = &s_ctrl->sensordata->power_info;
|
||||
|
||||
if (cmd->op_code != CAM_SENSOR_PROBE_CMD) {
|
||||
if (cmd->handle_type != CAM_HANDLE_USER_POINTER) {
|
||||
CAM_ERR(CAM_SENSOR, "Invalid handle type: %d",
|
||||
|
||||
Reference in New Issue
Block a user