[ofa-general] [PATCH] Use vmalloc to alloc the rx_ring

Roland Dreier rdreier at cisco.com
Thu Aug 7 09:41:26 PDT 2008


What is the severity of this issue?  Is this a patch for 2.6.27?

 > -	rx->rx_ring = kcalloc(ipoib_recvq_size, sizeof *rx->rx_ring, GFP_KERNEL);
 > -	if (!rx->rx_ring)
 > +	rx->rx_ring = vmalloc( ipoib_recvq_size * sizeof *rx->rx_ring);

no space after '(' here.

 > +
 > +	if (!rx->rx_ring){
 > +		printk(KERN_WARNING "ipoib_cm:Allocation of rx_ring failed, %s",
 > +			"try using a lower value of recv_queue_size.\n");
 >  		return -ENOMEM;
 > +	}
 >  
 >  	t = kmalloc(sizeof *t, GFP_KERNEL);
 >  	if (!t) {

Seems you are replacing kcalloc with vmalloc, but I don't see anything
that clears the memory you allocate.

 > +	priv->cm.srq_ring = vmalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring);
 > +
 >  	if (!priv->cm.srq_ring) {
 >  		printk(KERN_WARNING "%s: failed to allocate CM SRQ ring (%d entries)\n",
 >  		       priv->ca->name, ipoib_recvq_size);
 >  		ib_destroy_srq(priv->cm.srq);
 >  		priv->cm.srq = NULL;
 >  	}
 > +	memset(priv->cm.srq_ring, 0, 
 > +			ipoib_recvq_size * sizeof *priv->cm.srq_ring);

And here it seems if the allocation fail, you go on to zero out the ring
anyway.  (Not to mention trailing whitespace on the memset line :)

 - R.



More information about the general mailing list