File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -790,6 +790,9 @@ static struct iommu_device *mtk_iommu_probe_device(struct device *dev)
790
790
* All the ports in each a device should be in the same larbs.
791
791
*/
792
792
larbid = MTK_M4U_TO_LARB (fwspec -> ids [0 ]);
793
+ if (larbid >= MTK_LARB_NR_MAX )
794
+ return ERR_PTR (- EINVAL );
795
+
793
796
for (i = 1 ; i < fwspec -> num_ids ; i ++ ) {
794
797
larbidx = MTK_M4U_TO_LARB (fwspec -> ids [i ]);
795
798
if (larbid != larbidx ) {
@@ -799,6 +802,9 @@ static struct iommu_device *mtk_iommu_probe_device(struct device *dev)
799
802
}
800
803
}
801
804
larbdev = data -> larb_imu [larbid ].dev ;
805
+ if (!larbdev )
806
+ return ERR_PTR (- EINVAL );
807
+
802
808
link = device_link_add (dev , larbdev ,
803
809
DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS );
804
810
if (!link )
Original file line number Diff line number Diff line change 78
78
/* MTK generation one iommu HW only support 4K size mapping */
79
79
#define MT2701_IOMMU_PAGE_SHIFT 12
80
80
#define MT2701_IOMMU_PAGE_SIZE (1UL << MT2701_IOMMU_PAGE_SHIFT)
81
+ #define MT2701_LARB_NR_MAX 3
81
82
82
83
/*
83
84
* MTK m4u support 4GB iova address space, and only support 4K page
@@ -486,6 +487,9 @@ static struct iommu_device *mtk_iommu_v1_probe_device(struct device *dev)
486
487
487
488
/* Link the consumer device with the smi-larb device(supplier) */
488
489
larbid = mt2701_m4u_to_larb (fwspec -> ids [0 ]);
490
+ if (larbid >= MT2701_LARB_NR_MAX )
491
+ return ERR_PTR (- EINVAL );
492
+
489
493
for (idx = 1 ; idx < fwspec -> num_ids ; idx ++ ) {
490
494
larbidx = mt2701_m4u_to_larb (fwspec -> ids [idx ]);
491
495
if (larbid != larbidx ) {
@@ -496,6 +500,9 @@ static struct iommu_device *mtk_iommu_v1_probe_device(struct device *dev)
496
500
}
497
501
498
502
larbdev = data -> larb_imu [larbid ].dev ;
503
+ if (!larbdev )
504
+ return ERR_PTR (- EINVAL );
505
+
499
506
link = device_link_add (dev , larbdev ,
500
507
DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS );
501
508
if (!link )
You can’t perform that action at this time.
0 commit comments