Re: [PATCH] [workqueue] check values of pwq and wq inprint_worker_info() before use

From: Tejun Heo
Date: Tue Oct 01 2013 - 18:40:34 EST


Hello,

On Wed, Oct 02, 2013 at 12:34:53AM +0200, Helge Deller wrote:
> Sure, probe_kernel_read() takes care that no segfaults will happen.
> Nevertheless, if we know that "pwq" might become NULL, why access pwq->wq at all?
> struct pool_workqueue *pwq = NULL;
> probe_kernel_read(&wq, &pwq>wq, sizeof(wq));
>
> If you wouldn't have used probe_kernel_read() you would never code it
> like that. That's what I meant when I wrote "clean coding" (aka "similar
> to what you would have done without probe_kernel_read()").

Because it is using probe_kernel_read() and such test wouldn't mean
anything? It may be NULL, it may be 1 or full Fs. NULL is just one
of many illegal pointers which may happen. Why add code which doesn't
achieve anything when you're explicitly trying to access pointers
which you know could be invalid? Why is that "clean"? Is "if (p)
kfree(p)" cleaner than "kfree(p)"?

Thanks.

--
tejun
--
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/