lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 4 Jul 2013 16:33:23 +0300
From:	Jack Morgenstein <jackm@....mellanox.co.il>
To:	Joe Perches <joe@...ches.com>
Cc:	Or Gerlitz <ogerlitz@...lanox.com>, roland@...nel.org,
	linux-rdma@...r.kernel.org, netdev@...r.kernel.org,
	davem@...emloft.net, eli@....mellanox.co.il, moshel@...lanox.com,
	Eli Cohen <eli@...lanox.com>
Subject: Re: [PATCH V2 7/9] IB/mlx5: Mellanox Connect-IB, IB driver part 3/5

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 <eli@...lanox.com>
> 
> 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 netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ