Message ID | 1584624298-23841-4-git-send-email-liweihang@huawei.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | RDMA/hns: Various cleanups | expand |
On Thu, Mar 19, 2020 at 09:24:50PM +0800, Weihang Li wrote: > From: Yixian Liu <liuyixian@huawei.com> > > As the return value of kmalloc may be null or error code, use kernel macro > to do return value check. kmalloc always returns null, do not use IS_ERR_OR_NULL Jason
On 2020/3/20 2:18, Jason Gunthorpe wrote: > On Thu, Mar 19, 2020 at 09:24:50PM +0800, Weihang Li wrote: >> From: Yixian Liu <liuyixian@huawei.com> >> >> As the return value of kmalloc may be null or error code, use kernel macro >> to do return value check. > > kmalloc always returns null, do not use IS_ERR_OR_NULL > > Jason > OK, will drop this one in v2. Thank you Weihang
diff --git a/drivers/infiniband/hw/hns/hns_roce_cmd.c b/drivers/infiniband/hw/hns/hns_roce_cmd.c index 455d533..d52311a 100644 --- a/drivers/infiniband/hw/hns/hns_roce_cmd.c +++ b/drivers/infiniband/hw/hns/hns_roce_cmd.c @@ -268,7 +268,7 @@ struct hns_roce_cmd_mailbox struct hns_roce_cmd_mailbox *mailbox; mailbox = kmalloc(sizeof(*mailbox), GFP_KERNEL); - if (!mailbox) + if (IS_ERR_OR_NULL(mailbox)) return ERR_PTR(-ENOMEM); mailbox->buf = dma_pool_alloc(hr_dev->cmd.pool, GFP_KERNEL,