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] [thread-next>] [day] [month] [year] [list]
Message-ID: <m163qg62bu.fsf@frodo.ebiederm.org>
Date:	Mon, 04 Aug 2008 11:51:33 -0700
From:	ebiederm@...ssion.com (Eric W. Biederman)
To:	Alan Cox <alan@...rguk.ukuu.org.uk>
Cc:	Yinghai Lu <yhlu.kernel@...il.com>, Ingo Molnar <mingo@...e.hu>,
	Thomas Gleixner <tglx@...utronix.de>,
	"H. Peter Anvin" <hpa@...or.com>,
	Dhaval Giani <dhaval@...ux.vnet.ibm.com>,
	Mike Travis <travis@....com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 21/25] serial: change remove NR_IRQS in 8250.c v2

Alan Cox <alan@...rguk.ukuu.org.uk> writes:

>> Looks like we can also tweak serial_do_unlink to free irq_info when
>> the list goes empty, so we don't have a leak if the driver is ever
>> unloaded.
>
> Like this (again not yet tested) 
>
> 8250: Remove NR_IRQ usage
>
> From: Alan Cox <alan@...hat.com>

I think we've just about got it.

>  /*
>   * Here we define the default xmit fifo size used for each type of UART.
> @@ -1541,9 +1545,32 @@ static void serial_do_unlink(struct irq_info *i, struct
> uart_8250_port *up)
>  
>  static int serial_link_irq_chain(struct uart_8250_port *up)
>  {
> -	struct irq_info *i = irq_lists + up->port.irq;
> +	struct hlist_head *h;
> +	struct hlist_node *n;
> +	struct irq_info *i;
>  	int ret, irq_flags = up->port.flags & UPF_SHARE_IRQ ? IRQF_SHARED : 0;
>  
> +	mutex_lock(&hash_mutex);
> +
> +	h = &irq_lists[up->port.irq % NR_IRQ_HASH];
> +	
> +	hlist_for_each(n, h) {
> +		i = hlist_entry(n, struct irq_info, node);
> +		if (i->irq == up->port.irq)
> +			break;
> +	}
> +
> +	if (n == NULL) {
> +		i = kzalloc(sizeof(struct irq_info), GFP_KERNEL);
> +		if (i == NULL) {
> +			mutex_unlock(&hash_mutex);
> +			return -ENOMEM;
> +		}
> +		spin_lock_init(&i->lock);
> +		hlist_add_head(&i->node, h);
> +	}
> +	mutex_unlock(&hash_mutex);
> +
>  	spin_lock_irq(&i->lock);
>  
>  	if (i->head) {

Note there is also an error path that calls serial_do_unlink in serial_link_irq_chain.
That we might want to free the entry in.  Do we want move hash table entry freeing
into serial_do_unlink or duplicate it here?

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