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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Wed, 11 Aug 2010 18:23:28 +0200 (CEST)
From:	Julia Lawall <julia@...u.dk>
To:	Patrick Gefre <pfg@....com>
Cc:	linux-ia64@...r.kernel.org, linux-mips@...ux-mips.org,
	linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH 5/5] drivers/serial: Return -ENOMEM on memory allocation
 failure

> > I believe this code also leaks earlier instances of port, which are only
> > referenced by card_ptr, which is freed in the error handling code at the
> > end of the function.  A lot of operations are done on port on each
> > iteration, however, so I'm not sure whether it is good enough to just free
> > them.  Perhaps there is some way to call ioc3uart_remove?
> > 
> 
> Yes you are right, there should be something like this for out4:
> 
> out4:
> 	for (phys_port = 0; phys_port < PORTS_PER_CARD; phys_port++) {
> 		port = card_ptr->ic_port[phys_port].icp_port;
> 		if (port) {
> 			pci_free_consistent(port->ip_idd->pdev,
>                                        TOTAL_RING_BUF_SIZE,
>                                        (void *)port->ip_cpu_ringbuf,
>                                        port->ip_dma_ringbuf);
> 			kfree(port);
> 		}
> 	}
> 	kfree(card_ptr);
> 	return ret;

Actually, pci_alloc_consistent is only called when phys_port is 0.  In the 
subsequent cases, the ip_dma_ringbuf field is just initialized to the 
previous value.  So it could be:

out4:
        for (phys_port = 0; phys_port < PORTS_PER_CARD; phys_port++) {
                port = card_ptr->ic_port[phys_port].icp_port;
                if (port) {
			if (phys_port == 0)
	                        pci_free_consistent(port->ip_idd->pdev,
                                       TOTAL_RING_BUF_SIZE,
                                       (void *)port->ip_cpu_ringbuf,
                                       port->ip_dma_ringbuf);
                        kfree(port);
                }
        }
        kfree(card_ptr);
        return ret;

julia
--
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