Explorar o código

msm: camera: common: Added missing NULL Checks

This change is returning error for the cases
when platform device misses some data for
device or sub device. Adding Null pointer
checks resolves this issue.

CRs-Fixed: 3608850
Change-Id: If8fc3fc7c93bb2b95087674165dca8c1c13d54f6
Signed-off-by: Sourabh Soni <[email protected]>
Sourabh Soni hai 1 ano
pai
achega
eeb2706049

+ 8 - 1
drivers/cam_cust/cam_custom_hw_mgr/cam_custom_csid/cam_custom_csid_dev.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/slab.h>
@@ -107,13 +108,19 @@ err:
 static void cam_custom_csid_component_unbind(struct device *dev,
 	struct device *master_dev, void *data)
 {
-	struct cam_hw_intf             *csid_hw_intf;
+	struct cam_hw_intf             *csid_hw_intf = NULL;
 	struct cam_hw_info             *csid_hw_info;
 	struct cam_ife_csid_core_info  *core_info = NULL;
 	struct platform_device *pdev = to_platform_device(dev);
 	const struct of_device_id      *match_dev = NULL;
 
 	csid_hw_intf = (struct cam_hw_intf *)platform_get_drvdata(pdev);
+
+	if (!csid_hw_intf) {
+		CAM_ERR(CAM_CUSTOM, "ERROR No data in csid_hw_intf");
+		return;
+	}
+
 	csid_hw_info = csid_hw_intf->hw_priv;
 	core_info = csid_hw_info->core_info;
 

+ 7 - 1
drivers/cam_icp/icp_hw/bps_hw/bps_dev.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/module.h>
@@ -205,6 +205,12 @@ static void cam_bps_component_unbind(struct device *dev,
 
 	CAM_DBG(CAM_ICP, "Unbinding component: %s", pdev->name);
 	bps_dev_intf = platform_get_drvdata(pdev);
+
+	if (!bps_dev_intf) {
+		CAM_ERR(CAM_ICP, "Error No data in pdev");
+		return;
+	}
+
 	bps_dev = bps_dev_intf->hw_priv;
 	core_info = (struct cam_bps_device_core_info *)bps_dev->core_info;
 	cam_cpas_unregister_client(core_info->cpas_handle);

+ 7 - 1
drivers/cam_icp/icp_hw/icp_proc/icp_v1_hw/cam_icp_v1_dev.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/module.h>
@@ -212,6 +212,12 @@ static void cam_icp_v1_component_unbind(struct device *dev,
 	struct platform_device *pdev = to_platform_device(dev);
 
 	icp_v1_dev_intf = platform_get_drvdata(pdev);
+
+	if (!icp_v1_dev_intf) {
+		CAM_ERR(CAM_ICP, "Error No data in pdev");
+		return;
+	}
+
 	icp_v1_dev = icp_v1_dev_intf->hw_priv;
 	core_info = (struct cam_icp_v1_device_core_info *)icp_v1_dev->core_info;
 

+ 12 - 3
drivers/cam_icp/icp_hw/icp_proc/icp_v2_hw/cam_icp_v2_dev.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/module.h>
@@ -165,8 +165,17 @@ static void cam_icp_v2_component_unbind(struct device *dev,
 	struct device *mdev, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
-	struct cam_hw_intf *icp_v2_intf = platform_get_drvdata(pdev);
-	struct cam_hw_info *icp_v2_info = icp_v2_intf->hw_priv;
+	struct cam_hw_intf *icp_v2_intf = NULL;
+	struct cam_hw_info *icp_v2_info = NULL;
+
+	icp_v2_intf = platform_get_drvdata(pdev);
+
+	if (!icp_v2_intf) {
+		CAM_ERR(CAM_ICP, "Error No data in pdev");
+		return;
+	}
+
+	icp_v2_info = icp_v2_intf->hw_priv;
 
 	cam_icp_v2_cpas_unregister(icp_v2_intf);
 	cam_icp_soc_resources_deinit(&icp_v2_info->soc_info);

+ 6 - 0
drivers/cam_icp/icp_hw/ipe_hw/ipe_dev.c

@@ -188,6 +188,12 @@ static void cam_ipe_component_unbind(struct device *dev,
 
 	CAM_DBG(CAM_ICP, "Unbinding component: %s", pdev->name);
 	ipe_dev_intf = platform_get_drvdata(pdev);
+
+	if (!ipe_dev_intf) {
+		CAM_ERR(CAM_ICP, "Error No data in pdev");
+		return;
+	}
+
 	ipe_dev = ipe_dev_intf->hw_priv;
 	core_info = (struct cam_ipe_device_core_info *)ipe_dev->core_info;
 	cam_cpas_unregister_client(core_info->cpas_handle);

+ 6 - 0
drivers/cam_icp/icp_hw/ofe_hw/ofe_dev.c

@@ -184,6 +184,12 @@ static void cam_ofe_component_unbind(struct device *dev,
 
 	CAM_DBG(CAM_ICP, "Unbinding component: %s", pdev->name);
 	ofe_dev_intf = platform_get_drvdata(pdev);
+
+	if (!ofe_dev_intf) {
+		CAM_ERR(CAM_ICP, "Error No data in pdev");
+		return;
+	}
+
 	ofe_dev = ofe_dev_intf->hw_priv;
 	core_info = (struct cam_ofe_device_core_info *)ofe_dev->core_info;
 	cam_cpas_unregister_client(core_info->cpas_handle);

+ 6 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_dev.c

@@ -116,6 +116,12 @@ static void cam_ife_csid_component_unbind(struct device *dev,
 	const struct of_device_id      *match_dev = NULL;
 
 	hw_intf = (struct cam_hw_intf *)platform_get_drvdata(pdev);
+
+	if (!hw_intf) {
+		CAM_ERR(CAM_ISP, "Error No data in hw_intf");
+		return;
+	}
+
 	hw_info = hw_intf->hw_priv;
 
 	CAM_DBG(CAM_ISP, "CSID:%d component unbind",

+ 7 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/ppi_hw/cam_csid_ppi_dev.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/slab.h>
@@ -108,6 +109,12 @@ static void cam_ppi_component_unbind(struct device *dev,
 	struct platform_device *pdev = to_platform_device(dev);
 
 	ppi_dev = (struct cam_csid_ppi_hw *)platform_get_drvdata(pdev);
+
+	if (!ppi_dev) {
+		CAM_ERR(CAM_ISP, "Error No data in ppi_dev");
+		return;
+	}
+
 	ppi_hw_intf = ppi_dev->hw_intf;
 	ppi_hw_info = ppi_dev->hw_info;
 

+ 7 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid_dev.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/slab.h>
@@ -107,6 +108,12 @@ void cam_tfe_csid_component_unbind(struct device *dev,
 	struct platform_device *pdev = to_platform_device(dev);
 
 	csid_dev = (struct cam_tfe_csid_hw *)platform_get_drvdata(pdev);
+
+	if (!csid_dev) {
+		CAM_ERR(CAM_ISP, "Error No data in csid_dev");
+		return;
+	}
+
 	csid_hw_intf = csid_dev->hw_intf;
 	csid_hw_info = csid_dev->hw_info;
 

+ 11 - 2
drivers/cam_sensor_module/cam_cci/cam_cci_dev.c

@@ -560,8 +560,17 @@ static void cam_cci_component_unbind(struct device *dev,
 	struct platform_device *pdev = to_platform_device(dev);
 
 	struct v4l2_subdev *subdev = platform_get_drvdata(pdev);
-	struct cci_device *cci_dev =
-		v4l2_get_subdevdata(subdev);
+	struct cci_device *cci_dev = cci_dev = v4l2_get_subdevdata(subdev);
+
+	if (!subdev) {
+		CAM_ERR(CAM_CCI, "Error No data in subdev");
+		return;
+	}
+
+	if (!cci_dev) {
+		CAM_ERR(CAM_CCI, "Error No data in cci_dev");
+		return;
+	}
 
 	if (!cci_dev) {
 		CAM_ERR(CAM_CCI, "cci_dev NULL");

+ 16 - 2
drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.c

@@ -607,8 +607,22 @@ static void cam_csiphy_component_unbind(struct device *dev,
 {
 	struct platform_device *pdev = to_platform_device(dev);
 
-	struct v4l2_subdev *subdev = platform_get_drvdata(pdev);
-	struct csiphy_device *csiphy_dev = v4l2_get_subdevdata(subdev);
+	struct v4l2_subdev *subdev = NULL;
+	struct csiphy_device *csiphy_dev = NULL;
+
+	subdev = platform_get_drvdata(pdev);
+
+	if (!subdev) {
+		CAM_ERR(CAM_CSIPHY, "Error No data in subdev");
+		return;
+	}
+
+	csiphy_dev = v4l2_get_subdevdata(subdev);
+
+	if (!csiphy_dev) {
+		CAM_ERR(CAM_CSIPHY, "Error No data in csiphy_dev");
+		return;
+	}
 
 	if (!csiphy_dev) {
 		CAM_ERR(CAM_CSIPHY, "csiphy_dev ptr is NULL");

+ 8 - 1
drivers/cam_sensor_module/cam_tpg/cam_tpg_dev.c

@@ -336,7 +336,14 @@ static void cam_tpg_component_unbind(struct device *dev,
 	struct device *master_dev, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
-	struct cam_tpg_device  *tpg_dev = platform_get_drvdata(pdev);
+	struct cam_tpg_device  *tpg_dev = NULL;
+
+	tpg_dev = platform_get_drvdata(pdev);
+
+	if (!tpg_dev) {
+		CAM_ERR(CAM_TPG, "Error No data in tpg_dev");
+		return;
+	}
 
 	CAM_INFO(CAM_TPG, "Unbind TPG component");
 	cam_cpas_unregister_client(tpg_dev->cpas_handle);