kernel: nvidia-oot: Fix Linux KMD coverity defects

Fix INT32-C  INT32-Cand INT08-C coverity defects
for cdi_mgr.c and tegracam_ctrls.c.

JIRA CAMERASW-32529

Change-Id: I97f915f94264d78ae8e493874ccf889c9183fc93
Signed-off-by: mijia <mijia@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3314543
Reviewed-by: Sudhir Vyas <svyas@nvidia.com>
Reviewed-by: Ankur Pawar <ankurp@nvidia.com>
Tested-by: Patrick Young <payoung@nvidia.com>
Reviewed-by: Frank Chen <frankc@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Ryan Li <ryanli@nvidia.com>
This commit is contained in:
mijia
2025-03-06 02:44:42 +00:00
committed by Jon Hunter
parent c4fb69048c
commit 5ad213c183
2 changed files with 11 additions and 2 deletions

View File

@@ -1085,6 +1085,7 @@ int tegracam_ctrl_handler_init(struct tegracam_ctrl_handler *handler)
const struct tegracam_ctrl_ops *ops = handler->ctrl_ops;
const u32 *cids = NULL;
u32 numctrls = 0;
u32 cid = 0;
u8 compound_control_default_byte_value = 0xff;
int i, j;
int err = 0;
@@ -1107,7 +1108,15 @@ int tegracam_ctrl_handler_init(struct tegracam_ctrl_handler *handler)
err = v4l2_ctrl_handler_init(&handler->ctrl_handler, numctrls);
for (i = 0, j = 0; i < numctrls; i++) {
u32 cid = i < ops->numctrls ? cids[i] : tegracam_def_cids[j++];
if (i < ops->numctrls) {
cid = cids[i];
} else {
cid = tegracam_def_cids[j];
if (check_add_overflow(j, 1, &j)) {
dev_err(dev, "Error wrapped in loop\n");
return -EINVAL;
}
}
int index = tegracam_get_ctrl_index(cid);
int size = 0;
if (index >= ARRAY_SIZE(ctrl_cfg_list)) {

View File

@@ -1805,7 +1805,7 @@ static int cdi_mgr_probe(struct platform_device *pdev)
if (root_node) {
model = of_get_property(root_node, "model", NULL);
dev_info(&pdev->dev, "platform name: %s\n", model);
if (!strcmp(model, "p3898-0010"))
if (model != NULL && !strcmp(model, "p3898-0010"))
cdi_mgr->isP3898 = true;
}