[dpdk-dev] [PATCH 06/10] net/dpaa2: fix possible use of uninitialized vars

Andrzej Ostruszka amo at semihalf.com
Thu Sep 5 18:04:59 CEST 2019


On 9/5/19 4:10 PM, Hemant Agrawal wrote:
> Hi Andrzei,
> 
>> -----Original Message-----
> 
>> diff --git a/drivers/net/dpaa2/mc/dpni.c b/drivers/net/dpaa2/mc/dpni.c
>> index 362cd476f..b74a1a317 100644
>> --- a/drivers/net/dpaa2/mc/dpni.c
>> +++ b/drivers/net/dpaa2/mc/dpni.c
>> @@ -1803,10 +1803,13 @@ int dpni_set_congestion_notification(struct
>> fsl_mc_io *mc_io,
>>  	cmd_params->qtype = qtype;
>>  	cmd_params->tc = tc_id;
>>  	cmd_params->congestion_point = cfg->cg_point;
>> -	cmd_params->cgid = (uint8_t)cfg->cgid;
>> -	cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id);
>> +	if (cfg->cg_point == DPNI_CP_CONGESTION_GROUP)
>> +		cmd_params->cgid = (uint8_t)cfg->cgid;
>> +	if (cfg->dest_cfg.dest_type != DPNI_DEST_NONE) {
>> +		cmd_params->dest_id = cpu_to_le32(cfg-
>>> dest_cfg.dest_id);
>> +		cmd_params->dest_priority = cfg->dest_cfg.priority;
>> +	}
> 
> [Hemant] what was the exact issues you are facing in this piece of code? 
> Please share your compiler and other env details. 
> 
>>  	cmd_params->notification_mode = cpu_to_le16(cfg-
>>> notification_mode);
>> -	cmd_params->dest_priority = cfg->dest_cfg.priority;

That was warning from compiler that neither of these:
- cfg->cgid
- cfg->dest_cfg.dest_id
- cfg->dest_cfg.dest_priority
is initialized in dpaa2_dev_tx_queue_setup() where this function is
called and they are used here.  This might be non issue - I've changed
the function here however since I though it would be better - but I
don't know this code, I'm just guessing that:
- cgid is meaningful only when cg_point is DPNI_CP_CONGESTION_GROUP
- dest_id/dest_priority are meaningful when dest_type is not DPNI_DEST_NONE.

That was developed on 19.05 and rebased to 19.11 and I was using gcc
(7.4) however today when I commented out those 'if' I did not got the
warning which I wanted to send here.  I'll try to figure out what has
changed that this is no longer reported (I think the compiler should
still report this).

Best regards
Andrzej

BTW.  In my original submission I've made a mistake with DPDK dev
e-mail, so I'm replying now with it corrected.


More information about the dev mailing list