[PATCH 5/5] staging/lustre/lnet: fix potential null pointer dereference

Oleg Drokin green at linuxhacker.ru
Sun Apr 27 23:28:27 UTC 2014


Hello!

On Apr 27, 2014, at 6:39 PM, Greg Kroah-Hartman wrote:
>> 
>> -	lnet_ni_notify_locked(ni, lp);
>> +	if (ni != NULL)
>> +		lnet_ni_notify_locked(ni, lp);
> 
> Why can't lnet_ni_notify_locked() accept NULL as an input?

It makes no sense, because then there is nowhere to send the notification.
That said, it appears a race is possible where one caller updated let_peer structure to ask for a notification
and then we fell through here with a NULL ni and called into lnet_ni_notify_locked
where we'd try to dereference this NULL ni.
But this is the only called that accepts separate ni and lp, where as the only other caller gets them from the same struct
where they are updated more in sync.

I guess it makes sense to update lnet_ni_notify_locked as a future-proofing excercise.

Thanks, I'll update this patch.

Bye,
    Oleg


More information about the devel mailing list