Skip to content

Commit 5156740

Browse files
Swami Reddy ReddyExactExampl
authored andcommitted
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>
1 parent ce5bc4e commit 5156740

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

techpack/camera/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
33
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
4-
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4+
* Copyright (c) 2023-2024, Qualcomm Innovation Center, Inc. All rights reserved.
55
*/
66

77
#include <linux/module.h>
@@ -787,13 +787,14 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
787787
int rc = 0, pkt_opcode = 0;
788788
int8_t retries = 3;
789789
struct cam_control *cmd = (struct cam_control *)arg;
790-
struct cam_sensor_power_ctrl_t *power_info =
791-
&s_ctrl->sensordata->power_info;
790+
struct cam_sensor_power_ctrl_t *power_info = NULL;
792791
if (!s_ctrl || !arg) {
793792
CAM_ERR(CAM_SENSOR, "s_ctrl is NULL");
794793
return -EINVAL;
795794
}
796795

796+
power_info = &s_ctrl->sensordata->power_info;
797+
797798
if (cmd->op_code != CAM_SENSOR_PROBE_CMD) {
798799
if (cmd->handle_type != CAM_HANDLE_USER_POINTER) {
799800
CAM_ERR(CAM_SENSOR, "Invalid handle type: %d",

0 commit comments

Comments
 (0)