diff mbox

usnic: correctly check failed allocation

Message ID 1444943715-31250-1-git-send-email-wuninsu@gmail.com (mailing list archive)
State Accepted
Headers show

Commit Message

Insu Yun Oct. 15, 2015, 9:15 p.m. UTC
Since ib_alloc_device returns allocated memory address, not error,
it should be checked as IS_NULL, not IS_ERR_OR_NULL.

Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
 drivers/infiniband/hw/usnic/usnic_ib_main.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Dave Goodell (dgoodell) Oct. 15, 2015, 9:34 p.m. UTC | #1
On Thu, Oct 15, 2015 at 09:15:15PM +0000, Insu Yun wrote:
> Since ib_alloc_device returns allocated memory address, not error,
> it should be checked as IS_NULL, not IS_ERR_OR_NULL.
> 
> Signed-off-by: Insu Yun <wuninsu@gmail.com>

Reviewed-by: Dave Goodell <dgoodell@cisco.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Doug Ledford Oct. 21, 2015, 8:43 p.m. UTC | #2
On 10/15/2015 05:15 PM, Insu Yun wrote:
> Since ib_alloc_device returns allocated memory address, not error,
> it should be checked as IS_NULL, not IS_ERR_OR_NULL.
> 
> Signed-off-by: Insu Yun <wuninsu@gmail.com>

Thanks, applied.

> ---
>  drivers/infiniband/hw/usnic/usnic_ib_main.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/usnic/usnic_ib_main.c b/drivers/infiniband/hw/usnic/usnic_ib_main.c
> index 34c49b8..cbc0514 100644
> --- a/drivers/infiniband/hw/usnic/usnic_ib_main.c
> +++ b/drivers/infiniband/hw/usnic/usnic_ib_main.c
> @@ -328,16 +328,15 @@ static void *usnic_ib_device_add(struct pci_dev *dev)
>  	netdev = pci_get_drvdata(dev);
>  
>  	us_ibdev = (struct usnic_ib_dev *)ib_alloc_device(sizeof(*us_ibdev));
> -	if (IS_ERR_OR_NULL(us_ibdev)) {
> +	if (!us_ibdev) {
>  		usnic_err("Device %s context alloc failed\n",
>  				netdev_name(pci_get_drvdata(dev)));
> -		return ERR_PTR(us_ibdev ? PTR_ERR(us_ibdev) : -EFAULT);
> +		return ERR_PTR(-EFAULT);
>  	}
>  
>  	us_ibdev->ufdev = usnic_fwd_dev_alloc(dev);
> -	if (IS_ERR_OR_NULL(us_ibdev->ufdev)) {
> -		usnic_err("Failed to alloc ufdev for %s with err %ld\n",
> -				pci_name(dev), PTR_ERR(us_ibdev->ufdev));
> +	if (!us_ibdev->ufdev) {
> +		usnic_err("Failed to alloc ufdev for %s\n", pci_name(dev));
>  		goto err_dealloc;
>  	}
>  
>
diff mbox

Patch

diff --git a/drivers/infiniband/hw/usnic/usnic_ib_main.c b/drivers/infiniband/hw/usnic/usnic_ib_main.c
index 34c49b8..cbc0514 100644
--- a/drivers/infiniband/hw/usnic/usnic_ib_main.c
+++ b/drivers/infiniband/hw/usnic/usnic_ib_main.c
@@ -328,16 +328,15 @@  static void *usnic_ib_device_add(struct pci_dev *dev)
 	netdev = pci_get_drvdata(dev);
 
 	us_ibdev = (struct usnic_ib_dev *)ib_alloc_device(sizeof(*us_ibdev));
-	if (IS_ERR_OR_NULL(us_ibdev)) {
+	if (!us_ibdev) {
 		usnic_err("Device %s context alloc failed\n",
 				netdev_name(pci_get_drvdata(dev)));
-		return ERR_PTR(us_ibdev ? PTR_ERR(us_ibdev) : -EFAULT);
+		return ERR_PTR(-EFAULT);
 	}
 
 	us_ibdev->ufdev = usnic_fwd_dev_alloc(dev);
-	if (IS_ERR_OR_NULL(us_ibdev->ufdev)) {
-		usnic_err("Failed to alloc ufdev for %s with err %ld\n",
-				pci_name(dev), PTR_ERR(us_ibdev->ufdev));
+	if (!us_ibdev->ufdev) {
+		usnic_err("Failed to alloc ufdev for %s\n", pci_name(dev));
 		goto err_dealloc;
 	}