Re: [PATCH] to select.c (and an apology)

From: willy@thepuffingroup.com
Date: Sun Jan 30 2000 - 23:22:49 EST


On Mon, Jan 31, 2000 at 03:56:03AM +0100, Patrick Mau wrote:
> +/*
> fds = (struct pollfd **)kmalloc(
> (1 + (nfds - 1) / POLLFD_PER_PAGE) * sizeof(struct pollfd *),
> GFP_KERNEL);
> +*/
> +
> + fds = (struct pollfd **)kmalloc((nfds * sizeof(struct pollfd *))
> + / POLLFD_PER_PAGE, GFP_KERNEL);

hang on, this looks bad. the division will always round down, leaving
you with too little memory allocated (unless POLLFD_PER_PAGE exactly
divides nfds * sizeof(void *), which it probably does). you want to do
something like:

(nfds * sizeof(void *) + POLLFD_PER_PAGE - 1) / POLLFD_PER_PAGE

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



This archive was generated by hypermail 2b29 : Mon Jan 31 2000 - 21:00:26 EST