Subject: Re: [PATCH net] netconsole: fix NULL pointer dereference

From: Nikolay Aleksandrov <[email-masked]>
Date: Fri, 25 Oct 2013 16:15:01 +0200

On 10/24/2013 10:59 PM, Francois Romieu wrote:
> Nikolay Aleksandrov <[email-masked]> :
>> On 10/24/2013 07:56 PM, David Miller wrote:
>>> From: "David Laight" <[email-masked]>
> [...]
>>>> Ditto - might be worth saying:
>>>>     /* Acquire lock to wait for any write_msg() to complete. */
>>>
>>> Something this subtle definitely requires a comment.
>>>
>> Okay, thank you all for the reviews. I will re-submit a v2 with
>> the comment edited.
> 
> "edited" as in "removed" because:
> 1. an irq disabling spinlock loudly states what the intent is ("hey, this
>    netconsole stuff could be concurrently used in irq or softirq context").
> 2. the target_list_lock spinlock itself tells where to look for:
> 
> drivers/net/netconsole.c
> [...]
> /* This needs to be a spinlock because write_msg() cannot sleep */
> static DEFINE_SPINLOCK(target_list_lock);
> 
I thought so too. Although I also mentioned the problem and that it involves
write_msg in the current comment:
+		/* We need to disable the netconsole before cleaning it up
+		 * otherwise we might end up in write_msg() with
+		 * nt->np.dev == NULL and nt->enabled == 1
+		 */

I thought this implies that the spinlock protects us against running with
write_msg().
It's fine by me either way (with or w/o the addition to the comment). It's up to
you Dave, do you still want it explicitly there ?