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] [day] [month] [year] [list]
Message-ID: <1444756134.93285.264.camel@localhost>
Date:	Tue, 13 Oct 2015 10:08:54 -0700
From:	Sudeep Dutt <sudeep.dutt@...el.com>
To:	Sudip Mukherjee <sudipm.mukherjee@...il.com>
Cc:	Sudeep Dutt <sudeep.dutt@...el.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH char-misc-next v3] misc: mic: fix memory leak

On Tue, 2015-10-13 at 22:36 +0530, Sudip Mukherjee wrote:
> In scif_node_connect() we were returning if the initialization of p2p_ji
> fails. But at that time p2p_ij has already been initialized and
> resources allocated for it. And since p2p_ij is not added to the list
> till now so we will have a leak.
> Lets deinitialize and release the resources connected to p2p_ij.
> 

Reviewed-by: Sudeep Dutt <sudeep.dutt@...el.com>

Thanks again for the fix.

> Signed-off-by: Sudip Mukherjee <sudip@...torindia.org>
> ---
> 
> v3: added unmapping the aperture
> v2: missed making the function as static
> 
>  drivers/misc/mic/scif/scif_nodeqp.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/mic/scif/scif_nodeqp.c b/drivers/misc/mic/scif/scif_nodeqp.c
> index 7180d56..c66ca1a 100644
> --- a/drivers/misc/mic/scif/scif_nodeqp.c
> +++ b/drivers/misc/mic/scif/scif_nodeqp.c
> @@ -435,6 +435,21 @@ free_p2p:
>  	return NULL;
>  }
>  
> +/* Uninitialize and release resources from a p2p mapping */
> +static void scif_deinit_p2p_info(struct scif_dev *scifdev,
> +				 struct scif_p2p_info *p2p)
> +{
> +	struct scif_hw_dev *sdev = scifdev->sdev;
> +
> +	dma_unmap_sg(&sdev->dev, p2p->ppi_sg[SCIF_PPI_MMIO],
> +		     p2p->sg_nentries[SCIF_PPI_MMIO], DMA_BIDIRECTIONAL);
> +	dma_unmap_sg(&sdev->dev, p2p->ppi_sg[SCIF_PPI_APER],
> +		     p2p->sg_nentries[SCIF_PPI_APER], DMA_BIDIRECTIONAL);
> +	scif_p2p_freesg(p2p->ppi_sg[SCIF_PPI_MMIO]);
> +	scif_p2p_freesg(p2p->ppi_sg[SCIF_PPI_APER]);
> +	kfree(p2p);
> +}
> +
>  /**
>   * scif_node_connect: Respond to SCIF_NODE_CONNECT interrupt message
>   * @dst: Destination node
> @@ -477,8 +492,10 @@ static void scif_node_connect(struct scif_dev *scifdev, int dst)
>  	if (!p2p_ij)
>  		return;
>  	p2p_ji = scif_init_p2p_info(dev_j, dev_i);
> -	if (!p2p_ji)
> +	if (!p2p_ji) {
> +		scif_deinit_p2p_info(dev_i, p2p_ij);
>  		return;
> +	}
>  	list_add_tail(&p2p_ij->ppi_list, &dev_i->p2p);
>  	list_add_tail(&p2p_ji->ppi_list, &dev_j->p2p);
>  


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ