From 4e09bf5f9756491d43c1a455553f722401b8dfcc Mon Sep 17 00:00:00 2001 From: Fernando Pacheco Date: Fri, 23 Oct 2020 13:56:35 -0700 Subject: [PATCH] msm: camera: smmu: Avoid NULL dereference in cam_smmu_alloc_firmware The iommu domain we grab from iommu_get_domain_for_dev can be NULL. Eventually we will hit a NULL dereference in the cam_smmu_alloc_firmware due to the missing check. Modify the existing check to account for the possiblity of a NULL domain and bail early. CRs-Fixed: 2804766 Change-Id: I201260c3559b847cfb0bf7f85226816af148671d Signed-off-by: Fernando Pacheco --- drivers/cam_smmu/cam_smmu_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cam_smmu/cam_smmu_api.c b/drivers/cam_smmu/cam_smmu_api.c index 48ac8f0ebeb9..e2fdfeed93a9 100644 --- a/drivers/cam_smmu/cam_smmu_api.c +++ b/drivers/cam_smmu/cam_smmu_api.c @@ -3552,7 +3552,7 @@ static int cam_smmu_setup_cb(struct cam_context_bank_info *cb, /* create a virtual mapping */ if (cb->io_support) { cb->domain = iommu_get_domain_for_dev(dev); - if (IS_ERR(cb->domain)) { + if (IS_ERR_OR_NULL(cb->domain)) { CAM_ERR(CAM_SMMU, "Error: create domain Failed"); rc = -ENODEV; goto end;