Skip to contentSkip to conversation

drivers/iommu/intel-iommu.c:3227 audit_iommu_capabilities() error: potentially dereferencing uninitialized 'first_drhd'.

PATCH New Dan Carpenter 1 participant 1 message Nov 15, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 4/7 drivers/iommu/intel-iommu.c:3227 audit_iommu_capabilities() error: potentially dereferencing uninitialized 'first_drhd'.

[ Gar... Screwed up the from header again. Sorry. -dan ]

tree:   https://github.com/km13park/linux-1.git master
head:   ab295c14dacea474a043ba57e1764a6ffd11f581
commit: d5ef6f395216c0250e11472921cd7fa31e035d6a [4/7] iommu/vt-d: Set minimum value when IOMMUs have inconsistencies

If you fix the issue, kindly add following tag

New smatch warnings:
drivers/iommu/intel-iommu.c:3227 audit_iommu_capabilities() error: potentially dereferencing uninitialized 'first_drhd'.

Old smatch warnings:
drivers/iommu/intel-iommu.c:823 device_to_iommu() error: we previously assumed 'pdev' could be null (see line 799) drivers/iommu/intel-iommu.c:2337 __domain_mapping() error: we previously assumed 'sg' could be null (see line 2244)

# https://github.com/km13park/linux-1/commit/d5ef6f395216c0250e11472921cd7fa31e035d6a
git remote add km13park-linux-1 https://github.com/km13park/linux-1.git
git remote update km13park-linux-1
git checkout d5ef6f395216c0250e11472921cd7fa31e035d6a
vim +/first_drhd +3227 drivers/iommu/intel-iommu.c

4c3351c5c04624 Kyung Min Park 2019-11-04  3219  void __init audit_iommu_capabilities(void)
4c3351c5c04624 Kyung Min Park 2019-11-04  3220  {
4c3351c5c04624 Kyung Min Park 2019-11-04  3221  	struct dmar_drhd_unit *first_drhd;
                                                                               ^^^^^^^^^^
4c3351c5c04624 Kyung Min Park 2019-11-04  3222  	struct dmar_drhd_unit *drhd;
4c3351c5c04624 Kyung Min Park 2019-11-04  3223  	struct intel_iommu *iommu;
4c3351c5c04624 Kyung Min Park 2019-11-04  3224  
4c3351c5c04624 Kyung Min Park 2019-11-04  3225  	iommus_sane = true;
5fb7aa7c9d079d Kyung Min Park 2019-11-04  3226  	iommu_svm_cap_sane = true;
d5ef6f395216c0 Kyung Min Park 2019-11-04 @3227  	min_mamv = CAP_MAMV_MASK & first_drhd->iommu->cap;
                                                                                   ^^^^^^^^^^^^^^^^^^^^^^

Uninitialized

d5ef6f395216c0 Kyung Min Park 2019-11-04  3228  	min_pss = ECAP_PSS_MASK & first_drhd->iommu->ecap;
4c3351c5c04624 Kyung Min Park 2019-11-04  3229  
4c3351c5c04624 Kyung Min Park 2019-11-04  3230  	rcu_read_lock();
4c3351c5c04624 Kyung Min Park 2019-11-04  3231  	first_drhd = list_first_or_null_rcu(&dmar_drhd_units, typeof(*drhd), list);
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4c3351c5c04624 Kyung Min Park 2019-11-04  3232  	for_each_iommu(iommu, drhd) {
4c3351c5c04624 Kyung Min Park 2019-11-04  3233  		check_capabilities(first_drhd->iommu, iommu);
4c3351c5c04624 Kyung Min Park 2019-11-04  3234  	}
76a803a257fbb7 Kyung Min Park 2019-11-01  3235  	for_each_iommu(iommu, drhd) {
76a803a257fbb7 Kyung Min Park 2019-11-01  3236  		if (!pi_support_sane)
76a803a257fbb7 Kyung Min Park 2019-11-01  3237  			iommu->cap = ~CAP_PI_MASK & iommu->cap;
76a803a257fbb7 Kyung Min Park 2019-11-01  3238  		if (!eafs_sane)
76a803a257fbb7 Kyung Min Park 2019-11-01  3239  			iommu->ecap = ~ECAP_EAFS_MASK & iommu->ecap;
76a803a257fbb7 Kyung Min Park 2019-11-01  3240  		if (!smts_sane)
76a803a257fbb7 Kyung Min Park 2019-11-01  3241  			iommu->ecap = ~ECAP_SMTS_MASK & iommu->ecap;
76a803a257fbb7 Kyung Min Park 2019-11-01  3242  		if (!slads_sane)
76a803a257fbb7 Kyung Min Park 2019-11-01  3243  			iommu->ecap = ~ECAP_SLADS_MASK & iommu->ecap;
d5ef6f395216c0 Kyung Min Park 2019-11-04  3244  		iommu->cap = min_mamv | (~CAP_MAMV_MASK & iommu->cap);
d5ef6f395216c0 Kyung Min Park 2019-11-04  3245  		iommu->ecap = min_pss | (~ECAP_PSS_MASK & iommu->ecap);
76a803a257fbb7 Kyung Min Park 2019-11-01  3246  	}
4c3351c5c04624 Kyung Min Park 2019-11-04  3247  	rcu_read_unlock();
4c3351c5c04624 Kyung Min Park 2019-11-04  3248  }

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation