lkml.org 
[lkml]   [2013]   [Oct]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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


\
 
 \ /
  Last update: 2013-10-02 01:01    [W:1.506 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site