CC: [email protected] BCC: [email protected] In-Reply-To: <[email protected]> References: <[email protected]> TO: Nicolin Chen <[email protected]> TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] TO: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected]
Hi Nicolin, I love your patch! Perhaps something to improve: [auto build test WARNING on joro-iommu/next] [also build test WARNING on tegra/for-next v5.19-rc1 next-20220610] [cannot apply to awilliam-vfio/next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/intel-lab-lkp/linux/commits/Nicolin-Chen/Simplify-vfio_iommu_type1-attach-detach-routine/20220606-143004 base: https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git next :::::: branch date: 4 days ago :::::: commit date: 4 days ago config: i386-randconfig-m021 (https://download.01.org/0day-ci/archive/20220611/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-3) 11.3.0 If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> smatch warnings: drivers/vfio/vfio_iommu_type1.c:2229 vfio_iommu_alloc_attach_domain() error: we previously assumed 'domain' could be null (see line 2191) drivers/vfio/vfio_iommu_type1.c:2229 vfio_iommu_alloc_attach_domain() error: dereferencing freed memory 'domain' vim +/domain +2229 drivers/vfio/vfio_iommu_type1.c 572f64c71e0fe3 Zenghui Yu 2020-10-22 2156 c1a4076891cf18 Nicolin Chen 2022-06-05 2157 static struct vfio_domain * c1a4076891cf18 Nicolin Chen 2022-06-05 2158 vfio_iommu_alloc_attach_domain(struct bus_type *bus, struct vfio_iommu *iommu, c1a4076891cf18 Nicolin Chen 2022-06-05 2159 struct vfio_iommu_group *group) c1a4076891cf18 Nicolin Chen 2022-06-05 2160 { c1a4076891cf18 Nicolin Chen 2022-06-05 2161 struct iommu_domain *new_domain; c1a4076891cf18 Nicolin Chen 2022-06-05 2162 struct vfio_domain *domain; c1a4076891cf18 Nicolin Chen 2022-06-05 2163 int ret = 0; c1a4076891cf18 Nicolin Chen 2022-06-05 2164 c1a4076891cf18 Nicolin Chen 2022-06-05 2165 /* Try to match an existing compatible domain */ c1a4076891cf18 Nicolin Chen 2022-06-05 2166 list_for_each_entry (domain, &iommu->domain_list, next) { c1a4076891cf18 Nicolin Chen 2022-06-05 2167 ret = iommu_attach_group(domain->domain, group->iommu_group); c1a4076891cf18 Nicolin Chen 2022-06-05 2168 if (ret == -EMEDIUMTYPE) c1a4076891cf18 Nicolin Chen 2022-06-05 2169 continue; c1a4076891cf18 Nicolin Chen 2022-06-05 2170 if (ret) c1a4076891cf18 Nicolin Chen 2022-06-05 2171 return ERR_PTR(ret); c1a4076891cf18 Nicolin Chen 2022-06-05 2172 list_add(&group->next, &domain->group_list); c1a4076891cf18 Nicolin Chen 2022-06-05 2173 return domain; c1a4076891cf18 Nicolin Chen 2022-06-05 2174 } c1a4076891cf18 Nicolin Chen 2022-06-05 2175 c1a4076891cf18 Nicolin Chen 2022-06-05 2176 new_domain = iommu_domain_alloc(bus); c1a4076891cf18 Nicolin Chen 2022-06-05 2177 if (!new_domain) c1a4076891cf18 Nicolin Chen 2022-06-05 2178 return ERR_PTR(-EIO); c1a4076891cf18 Nicolin Chen 2022-06-05 2179 c1a4076891cf18 Nicolin Chen 2022-06-05 2180 if (iommu->nesting) { c1a4076891cf18 Nicolin Chen 2022-06-05 2181 ret = iommu_enable_nesting(new_domain); c1a4076891cf18 Nicolin Chen 2022-06-05 2182 if (ret) c1a4076891cf18 Nicolin Chen 2022-06-05 2183 goto out_free_iommu_domain; c1a4076891cf18 Nicolin Chen 2022-06-05 2184 } c1a4076891cf18 Nicolin Chen 2022-06-05 2185 c1a4076891cf18 Nicolin Chen 2022-06-05 2186 ret = iommu_attach_group(new_domain, group->iommu_group); c1a4076891cf18 Nicolin Chen 2022-06-05 2187 if (ret) c1a4076891cf18 Nicolin Chen 2022-06-05 2188 goto out_free_iommu_domain; c1a4076891cf18 Nicolin Chen 2022-06-05 2189 c1a4076891cf18 Nicolin Chen 2022-06-05 2190 domain = kzalloc(sizeof(*domain), GFP_KERNEL); c1a4076891cf18 Nicolin Chen 2022-06-05 @2191 if (!domain) { c1a4076891cf18 Nicolin Chen 2022-06-05 2192 ret = -ENOMEM; c1a4076891cf18 Nicolin Chen 2022-06-05 2193 goto out_detach; c1a4076891cf18 Nicolin Chen 2022-06-05 2194 } c1a4076891cf18 Nicolin Chen 2022-06-05 2195 c1a4076891cf18 Nicolin Chen 2022-06-05 2196 domain->domain = new_domain; c1a4076891cf18 Nicolin Chen 2022-06-05 2197 vfio_test_domain_fgsp(domain); c1a4076891cf18 Nicolin Chen 2022-06-05 2198 c1a4076891cf18 Nicolin Chen 2022-06-05 2199 /* c1a4076891cf18 Nicolin Chen 2022-06-05 2200 * If the IOMMU can block non-coherent operations (ie PCIe TLPs with c1a4076891cf18 Nicolin Chen 2022-06-05 2201 * no-snoop set) then VFIO always turns this feature on because on Intel c1a4076891cf18 Nicolin Chen 2022-06-05 2202 * platforms it optimizes KVM to disable wbinvd emulation. c1a4076891cf18 Nicolin Chen 2022-06-05 2203 */ c1a4076891cf18 Nicolin Chen 2022-06-05 2204 if (new_domain->ops->enforce_cache_coherency) c1a4076891cf18 Nicolin Chen 2022-06-05 2205 domain->enforce_cache_coherency = c1a4076891cf18 Nicolin Chen 2022-06-05 2206 new_domain->ops->enforce_cache_coherency(new_domain); c1a4076891cf18 Nicolin Chen 2022-06-05 2207 c1a4076891cf18 Nicolin Chen 2022-06-05 2208 /* replay mappings on new domains */ c1a4076891cf18 Nicolin Chen 2022-06-05 2209 ret = vfio_iommu_replay(iommu, domain); c1a4076891cf18 Nicolin Chen 2022-06-05 2210 if (ret) c1a4076891cf18 Nicolin Chen 2022-06-05 2211 goto out_free_domain; c1a4076891cf18 Nicolin Chen 2022-06-05 2212 c1a4076891cf18 Nicolin Chen 2022-06-05 2213 /* c1a4076891cf18 Nicolin Chen 2022-06-05 2214 * An iommu backed group can dirty memory directly and therefore c1a4076891cf18 Nicolin Chen 2022-06-05 2215 * demotes the iommu scope until it declares itself dirty tracking c1a4076891cf18 Nicolin Chen 2022-06-05 2216 * capable via the page pinning interface. c1a4076891cf18 Nicolin Chen 2022-06-05 2217 */ c1a4076891cf18 Nicolin Chen 2022-06-05 2218 iommu->num_non_pinned_groups++; c1a4076891cf18 Nicolin Chen 2022-06-05 2219 c1a4076891cf18 Nicolin Chen 2022-06-05 2220 INIT_LIST_HEAD(&domain->group_list); c1a4076891cf18 Nicolin Chen 2022-06-05 2221 list_add(&group->next, &domain->group_list); c1a4076891cf18 Nicolin Chen 2022-06-05 2222 list_add(&domain->next, &iommu->domain_list); c1a4076891cf18 Nicolin Chen 2022-06-05 2223 vfio_update_pgsize_bitmap(iommu); c1a4076891cf18 Nicolin Chen 2022-06-05 2224 return domain; c1a4076891cf18 Nicolin Chen 2022-06-05 2225 c1a4076891cf18 Nicolin Chen 2022-06-05 2226 out_free_domain: c1a4076891cf18 Nicolin Chen 2022-06-05 2227 kfree(domain); c1a4076891cf18 Nicolin Chen 2022-06-05 2228 out_detach: c1a4076891cf18 Nicolin Chen 2022-06-05 @2229 iommu_detach_group(domain->domain, group->iommu_group); c1a4076891cf18 Nicolin Chen 2022-06-05 2230 out_free_iommu_domain: c1a4076891cf18 Nicolin Chen 2022-06-05 2231 iommu_domain_free(new_domain); c1a4076891cf18 Nicolin Chen 2022-06-05 2232 return ERR_PTR(ret); c1a4076891cf18 Nicolin Chen 2022-06-05 2233 } c1a4076891cf18 Nicolin Chen 2022-06-05 2234 -- 0-DAY CI Kernel Test Service https://01.org/lkp _______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
