[Suggestion] drivers: staging: dgrp: dgrp_net_ops.c: 'buf' is used without initialized.

Chen Gang gang.chen.5i5j at gmail.com
Tue Dec 10 05:56:12 UTC 2013


On 12/10/2013 01:17 PM, Greg KH wrote:
> On Tue, Dec 10, 2013 at 01:07:58PM +0800, Chen Gang wrote:
>> Hello Maintainers:
>>
>> The compiler help me find a warning about it, please help check thanks.
>>
>> The related git commit: "b73db54 Staging: dgrp: Refactor the function
>> dgrp_receive() in drrp_net_ops.c"
>>
>> The related warning (with allmodconfig for metag):
>>
>>     CC [M]  drivers/staging/dgrp/dgrp_net_ops.o
>>   drivers/staging/dgrp/dgrp_net_ops.c: In function 'handle_data_in_packet':
>>   drivers/staging/dgrp/dgrp_net_ops.c:2392: warning: 'buf' is used uninitialized in this function
> 
> Great, care to send a patch to fix this?
> 

Excuse me, I am not quite familiar with this driver details, after
reading the related code, I am still confusing (don't know what it
wants to do):


2390         if (remain < plen) {
2391                 dlen = plen - remain;
2392                 b = buf;				/* buf is uninitialized */
2393 
2394                 b[0] = 0x90 + n1;
2395                 put_unaligned_be16(dlen, b + 1);
2396 
2397                 remain = 3;
2398                 if (remain > 0 && b != buf)      /* 'remain' always > 0, 'b' always == 'buf' */
2399                         memcpy(buf, b, remain);  /* 'buf' is a stack pointer, will be lost after return from handel_data_in_packet() */
2400 
2401                 nd->nd_remain = remain;
2402                 return;
2403         }

Does it want to save the left information in a buffer which need be
still existent after return from handle_data_in_packet()?


And also welcome any members help send related patch for it.

Thanks.
-- 
Chen Gang

Open, share, and attitude like air, water and life which God blessed


More information about the devel mailing list