Messages in this thread | | | Date | Tue, 1 Oct 2013 18:40:23 -0400 | From | Tejun Heo <> | Subject | Re: [PATCH] [workqueue] check values of pwq and wq in print_worker_info() before use |
| |
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
| |