Skip to contentSkip to conversation

IB/usnic: clean up some error handling code

PATCH In review Dan Carpenter 2 participants 2 messages Jun 4, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IB/usnic: clean up some error handling code

This code causes a static checker warning:

drivers/infiniband/hw/usnic/usnic_uiom.c:476 usnic_uiom_alloc_pd()
warn: passing zero to 'PTR_ERR'

This code isn't buggy, but iommu_domain_alloc() doesn't return an error pointer so we can simplify the error handling and silence the static checker warning.

The static checker warning is to catch place which do:

	if (!ptr)
		return ERR_PTR(ptr);
drivers/infiniband/hw/usnic/usnic_uiom.c +3 -4
index 417de1f..cb2337f 100644
@@ -472,11 +472,10 @@ struct usnic_uiom_pd *usnic_uiom_alloc_pd(void)
 		return ERR_PTR(-ENOMEM);
 
 	pd->domain = domain = iommu_domain_alloc(&pci_bus_type);
-	if (IS_ERR_OR_NULL(domain)) {
-		usnic_err("Failed to allocate IOMMU domain with err %ld\n",
-				PTR_ERR(pd->domain));
+	if (!domain) {
+		usnic_err("Failed to allocate IOMMU domain");
 		kfree(pd);
-		return ERR_PTR(domain ? PTR_ERR(domain) : -ENOMEM);
+		return ERR_PTR(-ENOMEM);
 	}
 
 	iommu_set_fault_handler(pd->domain, usnic_uiom_dma_fault, NULL);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Dan Carpenter

This code causes a static checker warning:

drivers/infiniband/hw/usnic/usnic_uiom.c:476 usnic_uiom_alloc_pd()
warn: passing zero to 'PTR_ERR'

This code isn't buggy, but iommu_domain_alloc() doesn't return an error pointer so we can simplify the error handling and silence the static checker warning.

Quoted 6 lines

The static checker warning is to catch place which do:

	if (!ptr)
		return ERR_PTR(ptr);

Looks good to me, thanks.

-Dave