Re: [RFC v4][PATCH 8/9] File descriprtors (dump)
From: Vegard Nossum
Date: Tue Sep 09 2008 - 04:07:15 EST
On Tue, Sep 9, 2008 at 9:42 AM, Oren Laadan <orenl@xxxxxxxxxxxxxxx> wrote:
> + fdlist = kmalloc(max * sizeof(*fdlist), GFP_KERNEL);
> + if (!fdlist)
> + return -ENOMEM;
> +
> + spin_lock(&files->file_lock);
> + fdt = files_fdtable(files);
> + for (i = 0; i < fdt->max_fds; i++) {
> + if (!fcheck_files(files, i))
> + continue;
> + if (n == max) {
> + /* fcheck_files() is safe with drop/re-acquire
> + * of the lock, as it tests: fd < max_fds */
> + spin_unlock(&files->file_lock);
> + max *= 2;
> + if (max < 0) { /* overflow ? */
> + n = -EMFILE;
> + goto out;
> + }
> + fdlist = krealloc(fdlist, max, GFP_KERNEL);
Hm, shouldn't this be max * sizeof(*fdlist) like the kmalloc above?
Vegard
--
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
-- E. W. Dijkstra, EWD1036
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/