Skip to contentSkip to conversation

iommu: Introduce iommu_request_dm_for_dev()

DISCUSSION Dan Carpenter 2 participants 2 messages Jun 10, 2015 – Jun 11, 2015

lore
Share & tools
lore
#0 lore raw

Hello Joerg Roedel,

This is a semi-automatic email about new static checker warnings.

The patch eeae3fba3afe: "iommu: Introduce iommu_request_dm_for_dev()" from May 28, 2015, leads to the following Smatch complaint:

drivers/iommu/iommu.c:1581 iommu_request_dm_for_dev()

	 error: we previously assumed 'group->default_domain' could be null (see line 1558)

drivers/iommu/iommu.c
1557 /* Check if the default domain is already direct mapped */
1558 ret = 0;
1559 if (group->default_domain &&

                    ^^^^^^^^^^^^^^^^^^^^^

Check for NULL.

1560 group->default_domain->type == IOMMU_DOMAIN_IDENTITY)
1561 goto out;
1562
1563 /* Don't change mappings of existing devices */
1564 ret = -EBUSY;
1565 if (iommu_group_device_count(group) != 1)
1566 goto out;
1567
1568 /* Allocate a direct mapped domain */
1569 ret = -ENOMEM;
1570 dm_domain = __iommu_domain_alloc(dev->bus, IOMMU_DOMAIN_IDENTITY);
1571 if (!dm_domain)
1572 goto out;
1573
1574 /* Attach the device to the domain */
1575 ret = __iommu_attach_group(dm_domain, group);
1576 if (ret) {
1577 iommu_domain_free(dm_domain);
1578 goto out;
1579 }
1580
1581 /* Make the direct mapped domain the default for this group */

  1582		iommu_domain_free(group->default_domain);
                                  ^^^^^^^^^^^^^^^^^^^^^

Dereferenced inside function.

  1583		group->default_domain = dm_domain;

regards,
dan carpenter

#1 lore raw

Hi Dan,

Quoted 7 lines · Dan Carpenter

This is a semi-automatic email about new static checker warnings.

The patch eeae3fba3afe: "iommu: Introduce iommu_request_dm_for_dev()" from May 28, 2015, leads to the following Smatch complaint:

drivers/iommu/iommu.c:1581 iommu_request_dm_for_dev()

	 error: we previously assumed 'group->default_domain' could be null (see line 1558)

Thanks for the report, I folded a fix back into the patch introducing this function.

Joerg