Subject: Re: [patch -next v2] mv643xx_eth: potential null dereference

From: walter harms <[email-masked]>
Date: Sat, 24 Jul 2010 10:59:07 +0200

Dan Carpenter schrieb:
> On Fri, Jul 23, 2010 at 06:30:22PM +0200, walter harms wrote:
>> this is a bit complicated, IMHO ppl have a bigger chance to discover what is going on
>> with this version:
>>
>>     if (!pd ) {
>>        msp->t_clk = 133000000;
>>        msp->tx_csum_limit = 9 * 1024;
>>      }
>>      else
>>       {
>> 	msp->t_clk = pd->t_clk ? pd->t_clk : 133000000 ;
>>         msp->tx_csum_limit = pd->tx_csum_limit ? pd->tx_csum_limit : 9 * 1024;
>>        }
>>
> 
> But then instead of 2 magic numbers we would have 4. :/
> 

Yes it can be shorten,

msp->t_clk = 133000000;
msp->tx_csum_limit = 9 * 1024;
if (pd) {
	if (pd->t_clk) msp->t_clk = pd->t_clk ;
	if (pd->tx_csum_limit) sp->tx_csum_limit = pd->tx_csum_limit;
}
pd->t_clk
i was thinking about that in my first posting but i have the feeling that ppl
tend to overlook the "if (pd)" but in this case it is important since the
behavier is different.

IMHO it would be better to make sure that pd->t_clk,pd->tx_csum_limit have usefull
values than adding a check but this is up to the maintainer.

re,
 wh