Subject: Re: Crashes in xfrm_lookup

From: Timo Teräs <[email-masked]>
Date: Fri, 09 Apr 2010 11:11:48 +0300

Herbert Xu wrote:
> Timo Teräs <[email-masked]> wrote:
>> Happens because CONFIG_XFRM_SUB_POLICY is not enabled, and one of
>> the helper functions I used did unexpected things in that case.
>>
>> Try the following:
> 
> Ugh, can we fix this some other way?
> 
> The policy array should really only exist if SUB_POLICY is defined.

The problem was that my code could call it with zero polcies
assuming it'd do the right thing.

It's still really misleading to have generic function that does not
do the expected thing based on some config. Compiler should know
how to optimize the for loop away if it's being called with fixed
array size.