Re: [PATCH][next] mtd: rawnand: ensure return variable is initialized

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 27/05/2021 16:03, Miquel Raynal wrote:
> Hi Colin,
> 
> Colin King <colin.king@xxxxxxxxxxxxx> wrote on Thu, 27 May 2021
> 15:50:48 +0100:
> 
>> From: Colin Ian King <colin.king@xxxxxxxxxxxxx>
>>
>> Currently there are corner cases where spec_times is NULL and
>> chip->parameters.onfi or when best_mode is zero where ret is
> 
>                        ^
> something is missing here, the sentence is not clear
> 
>> not assigned a value and an uninitialized return value can be
>> returned. Fix this by ensuring ret is initialized to -EINVAL.
> 
> I don't see how this situation can happen.
> 
> In both cases, no matter the value of best_mode, the for loop will
> always execute at least one time (mode 0) so ret will be populated.
> 
> Maybe the robot does not know that best_mode cannot be negative and
> should be defined unsigned, but the current patch is invalid.

Yep, I've looked at this again and it does seem like a false positive.
Apologies for the noise.

> 
>> Addresses-Coverity: ("Uninitialized scalar variable")
>> Fixes: 9d3194bf2aef ("mtd: rawnand: Allow SDR timings to be nacked")
>> Fixes: a9ecc8c814e9 ("mtd: rawnand: Choose the best timings, NV-DDR included")
>> Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
>> ---
>>  drivers/mtd/nand/raw/nand_base.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
>> index 57a583149cc0..18db742f650c 100644
>> --- a/drivers/mtd/nand/raw/nand_base.c
>> +++ b/drivers/mtd/nand/raw/nand_base.c
>> @@ -926,7 +926,7 @@ int nand_choose_best_sdr_timings(struct nand_chip *chip,
>>  				 struct nand_sdr_timings *spec_timings)
>>  {
>>  	const struct nand_controller_ops *ops = chip->controller->ops;
>> -	int best_mode = 0, mode, ret;
>> +	int best_mode = 0, mode, ret = -EINVAL;
>>  
>>  	iface->type = NAND_SDR_IFACE;
>>  
>> @@ -977,7 +977,7 @@ int nand_choose_best_nvddr_timings(struct nand_chip *chip,
>>  				   struct nand_nvddr_timings *spec_timings)
>>  {
>>  	const struct nand_controller_ops *ops = chip->controller->ops;
>> -	int best_mode = 0, mode, ret;
>> +	int best_mode = 0, mode, ret = 0;
>>  
>>  	iface->type = NAND_NVDDR_IFACE;
>>  
> 
> Thanks,
> Miquèl
> 




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux