On Thursday 04 July 2013 00:10, Joe Perches wrote:
> On Wed, 2013-07-03 at 20:13 +0300, Or Gerlitz wrote:
> > From: Eli Cohen <[email protected]>
> 
> More trivia:
> 
> > diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h 
> > b/drivers/infiniband/hw/mlx5/mlx5_ib.h
> []
> > +#define mlx5_ib_dbg(dev, format, arg...)                           \
> > +do {                                                                       
> > \
> > +   pr_debug("%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name,      \
> > +            __func__, __LINE__, current->pid, ##arg);              \
> > +} while (0)
> 
> unnecessary do {} while (0)

In this case, you are correct. The pr_debug macro itself does this internally
where needed -- not surprising, since pr_debug must also be usable for code 
like:
if (foo)
        pr_debug(...).
I'll remove the do-while in V3.

> > +static void clean_keys(struct mlx5_ib_dev *dev, int c)
> > +{
> > +   struct device *ddev = dev->ib_dev.dma_device;
> > +   struct mlx5_mr_cache *cache = &dev->cache;
> > +   struct mlx5_cache_ent *ent = &cache->ent[c];
> > +   struct mlx5_ib_mr *mr;
> > +   int size;
> > +   int err;
> > +
> > +   while (1) {
> > +           spin_lock(&ent->lock);
> > +           if (list_empty(&ent->head)) {
> > +                   spin_unlock(&ent->lock);
> > +                   return;
> > +           }
> > +           mr = list_first_entry(&ent->head, struct mlx5_ib_mr, list);
> > +           list_del(&mr->list);
> > +           ent->cur--;
> > +           ent->size--;
> > +           spin_unlock(&ent->lock);
> > +           err = mlx5_core_destroy_mkey(&dev->mdev, &mr->mmr);
> > +           if (err) {
> > +                   mlx5_ib_warn(dev, "failed destroy mkey\n");
> 
> Are you leaking anything here by not freeing?
Actually, if the mkey-destroy fails, it is extremely risky to free
the memory resources it uses.  A tiny memory leak (in such a rare case)
is far preferable to a kernel crash.

> 
> > +           } else {
> > +                   size = ALIGN(sizeof(u64) * (1 << mr->order), 0x40);
> > +                   dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE);
> > +                   kfree(mr->pas);
> > +                   kfree(mr);
> > +           }
> > +   };
> > +}
> 
> > +static struct mlx5_ib_mr *reg_create(struct ib_pd *pd, u64 virt_addr,
> > +                                u64 length, struct ib_umem *umem,
> > +                                int npages, int page_shift,
> > +                                int access_flags)
> > +{
> []
> > +   mr = kzalloc(sizeof(*mr), GFP_KERNEL);
> > +   if (!mr) {
> > +           mlx5_ib_warn(dev, "allocation failed\n");
> 
> Another unnecessary OOM

Will remove for V3 

> > +           mr = ERR_PTR(-ENOMEM);
> > +   }
> > +
> > +   inlen = sizeof(*in) + sizeof(*in->pas) * ((npages + 1) / 2) * 2;
> > +   in = vzalloc(inlen);
> > +   if (!in) {
> > +           mlx5_ib_warn(dev, "alloc failed\n");
> 
> here too.

Will remove for V3 

> > +           err = -ENOMEM;
> > +           goto err_1;
> > +   }
> 
Thanks again for the review!

-Jack 
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to