Pārlūkot izejas kodu

disp: msm: fix kw issues in sde and dp driver

This change addresses out of range and null checks in
sde and dp driver.

Change-Id: I142196d7394f0bf0abab1bfa89abfd784a5521c8
Signed-off-by: Narendra Muppalla <[email protected]>
Narendra Muppalla 5 gadi atpakaļ
vecāks
revīzija
d07ef2efe0
3 mainītis faili ar 22 papildinājumiem un 10 dzēšanām
  1. 4 4
      msm/dp/dp_hpd.c
  2. 14 4
      msm/msm_gem.c
  3. 4 2
      msm/sde/sde_encoder_phys_cmd.c

+ 4 - 4
msm/dp/dp_hpd.c

@@ -46,21 +46,21 @@ struct dp_hpd *dp_hpd_get(struct device *dev, struct dp_parser *parser,
 
 	if (parser->no_aux_switch && parser->lphw_hpd) {
 		dp_hpd = dp_lphw_hpd_get(dev, parser, catalog, cb);
-		if (IS_ERR(dp_hpd)) {
+		if (IS_ERR_OR_NULL(dp_hpd)) {
 			DP_ERR("failed to get lphw hpd\n");
 			return dp_hpd;
 		}
 		dp_hpd->type = DP_HPD_LPHW;
 	} else if (parser->no_aux_switch) {
 		dp_hpd = dp_gpio_hpd_get(dev, cb);
-		if (IS_ERR(dp_hpd)) {
+		if (IS_ERR_OR_NULL(dp_hpd)) {
 			DP_ERR("failed to get gpio hpd\n");
 			return dp_hpd;
 		}
 		dp_hpd->type = DP_HPD_GPIO;
 	} else {
 		dp_hpd = dp_altmode_get(dev, cb);
-		if (!IS_ERR(dp_hpd)) {
+		if (!IS_ERR_OR_NULL(dp_hpd)) {
 			dp_hpd->type = DP_HPD_ALTMODE;
 			goto config;
 		}
@@ -68,7 +68,7 @@ struct dp_hpd *dp_hpd_get(struct device *dev, struct dp_parser *parser,
 				PTR_ERR(dp_hpd));
 
 		dp_hpd = dp_usbpd_get(dev, cb);
-		if (IS_ERR(dp_hpd)) {
+		if (IS_ERR_OR_NULL(dp_hpd)) {
 			DP_ERR("failed to get usbpd\n");
 			return dp_hpd;
 		}

+ 14 - 4
msm/msm_gem.c

@@ -114,8 +114,14 @@ static struct page **get_pages(struct drm_gem_object *obj)
 		 */
 		if (msm_obj->flags & (MSM_BO_WC|MSM_BO_UNCACHED)) {
 			aspace_dev = msm_gem_get_aspace_device(msm_obj->aspace);
-			dma_map_sg(aspace_dev, msm_obj->sgt->sgl,
-				msm_obj->sgt->nents, DMA_BIDIRECTIONAL);
+			if (aspace_dev)
+				dma_map_sg(aspace_dev, msm_obj->sgt->sgl,
+						msm_obj->sgt->nents,
+						DMA_BIDIRECTIONAL);
+			else
+				dev_err(dev->dev,
+					"failed to get aspace_device\n");
+
 		}
 	}
 
@@ -190,8 +196,12 @@ void msm_gem_sync(struct drm_gem_object *obj)
 	 * scatter/gather mapping for the CPU and device.
 	 */
 	aspace_dev = msm_gem_get_aspace_device(msm_obj->aspace);
-	dma_sync_sg_for_device(aspace_dev, msm_obj->sgt->sgl,
-		       msm_obj->sgt->nents, DMA_BIDIRECTIONAL);
+	if (aspace_dev)
+		dma_sync_sg_for_device(aspace_dev, msm_obj->sgt->sgl,
+				msm_obj->sgt->nents, DMA_BIDIRECTIONAL);
+	else
+		dev_err(obj->dev->dev,
+			"failed to get aspace_device\n");
 }
 
 

+ 4 - 2
msm/sde/sde_encoder_phys_cmd.c

@@ -321,10 +321,10 @@ static void _sde_encoder_phys_cmd_setup_irq_hw_idx(
 		struct sde_encoder_phys *phys_enc)
 {
 	struct sde_encoder_irq *irq;
-	struct sde_kms *sde_kms = phys_enc->sde_kms;
+	struct sde_kms *sde_kms;
 	int ret = 0;
 
-	if (!phys_enc || !phys_enc->hw_pp || !phys_enc->hw_ctl) {
+	if (!phys_enc->sde_kms || !phys_enc->hw_pp || !phys_enc->hw_ctl) {
 		SDE_ERROR("invalid args %d %d\n", !phys_enc,
 			phys_enc ? !phys_enc->hw_pp : 0);
 		return;
@@ -335,6 +335,8 @@ static void _sde_encoder_phys_cmd_setup_irq_hw_idx(
 		return;
 	}
 
+	sde_kms = phys_enc->sde_kms;
+
 	mutex_lock(&sde_kms->vblank_ctl_global_lock);
 
 	if (atomic_read(&phys_enc->vblank_refcount)) {