All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizefan@huawei.com>
To: li guang <lig.fnst@cn.fujitsu.com>
Cc: Oleg Nesterov <oleg@redhat.com>, <viro@zeniv.linux.org.uk>,
	<edumazet@google.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] task_work: check callback if it's NULL
Date: Fri, 15 Mar 2013 09:43:00 +0800	[thread overview]
Message-ID: <51427CA4.2060803@huawei.com> (raw)
In-Reply-To: <1363310769.21129.132.camel@liguang.fnst.cn.fujitsu.com>

On 2013/3/15 9:26, li guang wrote:
> 在 2013-03-15五的 09:01 +0800,Li Zefan写道:
>> On 2013/3/15 8:20, li guang wrote:
>>> 在 2013-03-14四的 15:43 +0100,Oleg Nesterov写道:
>>>> On 03/14, liguang wrote:
>>>>>
>>>>> Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
>>>>> ---
>>>>>  kernel/task_work.c |    3 ++-
>>>>>  1 files changed, 2 insertions(+), 1 deletions(-)
>>>>>
>>>>> diff --git a/kernel/task_work.c b/kernel/task_work.c
>>>>> index 0bf4258..f458b08 100644
>>>>> --- a/kernel/task_work.c
>>>>> +++ b/kernel/task_work.c
>>>>> @@ -75,7 +75,8 @@ void task_work_run(void)
>>>>>
>>>>>  		do {
>>>>>  			next = work->next;
>>>>> -			work->func(work);
>>>>> +			if (unlikely(work->func))
>>>>> +				work->func(work);
>>>>
>>>> Why?
>>>>
>>>> Oleg.
>>>>
>>>
>>> can we believe a callback always be call-able?
>>> can it happened to be 0? e.g. wrong initialized.
>>> of course, we can complain the caller, be why don't
>>> we easily make it more safer?
>>>
>>
>> Because you're not making things safer, but your're trying
>> to cover up bugs...
>>
> 
> Oh, that's a little harsh to a normal programmer like me :-)
> for it seems you are asking me to be coding without any bug.
> are you? or it is the theory of kernel coding?
> 

And you make a bug, and you want the kernel to cover up the bug
instead of crash on a null pointer deref so you'll know you've
made a bug?

Why we check if a callback is NULL before calling it? Because
it's allowed to be. Why we don't check if a callback is NULL?
Because it's not supposed to be.


  reply	other threads:[~2013-03-15  1:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-14  7:57 [PATCH 1/2] task_work: make FIFO task_work list liguang
2013-03-14  7:57 ` [PATCH 2/2] task_work: check callback if it's NULL liguang
2013-03-14 14:43   ` Oleg Nesterov
2013-03-15  0:20     ` li guang
2013-03-15  1:01       ` Li Zefan
2013-03-15  1:26         ` li guang
2013-03-15  1:43           ` Li Zefan [this message]
2013-03-15  2:29             ` li guang
2013-03-14 14:40 ` [PATCH 1/2] task_work: make FIFO task_work list Oleg Nesterov
2013-03-15  0:16   ` li guang
2013-03-15 14:34     ` Oleg Nesterov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51427CA4.2060803@huawei.com \
    --to=lizefan@huawei.com \
    --cc=edumazet@google.com \
    --cc=lig.fnst@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.