diff mbox series

[net-next,1/3] ptp: ocp: Fix uninitialized variable warning spotted by clang.

Message ID 20210811183133.186721-2-jonathan.lemon@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series ptp: ocp: minor updates | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 3 maintainers not CCed: clang-built-linux@googlegroups.com ndesaulniers@google.com nathan@kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Jonathan Lemon Aug. 11, 2021, 6:31 p.m. UTC
If attempting to flash the firmware with a blob of size 0,
the entire write loop is skipped and the uninitialized err
is returned.  Fix by setting to 0 first.

Also remove a now-unused error handling statement.

Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
---
 drivers/ptp/ptp_ocp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Jakub Kicinski Aug. 12, 2021, 9:58 p.m. UTC | #1
On Wed, 11 Aug 2021 11:31:31 -0700 Jonathan Lemon wrote:
> If attempting to flash the firmware with a blob of size 0,
> the entire write loop is skipped and the uninitialized err
> is returned.  Fix by setting to 0 first.
> 
> Also remove a now-unused error handling statement.
> 
> Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
> ---
>  drivers/ptp/ptp_ocp.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 92edf772feed..9b2ba06ebf97 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -763,7 +763,7 @@ ptp_ocp_devlink_flash(struct devlink *devlink, struct device *dev,
>  	size_t off, len, resid, wrote;
>  	struct erase_info erase;
>  	size_t base, blksz;
> -	int err;
> +	int err = 0;
>  
>  	off = 0;
>  	base = bp->flash_start;
> @@ -847,8 +847,6 @@ ptp_ocp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
>  							       "loader",
>  							       buf);
>  		}
> -		if (err)
> -			return err;

Looks like an accidental change, but it's mentioned in the commit log?

>  	}
>  
>  	if (!bp->has_serial)
Jonathan Lemon Aug. 12, 2021, 10:06 p.m. UTC | #2
> On Aug 12, 2021, at 2:58 PM, Jakub Kicinski <kuba@kernel.org> wrote:
> 
> On Wed, 11 Aug 2021 11:31:31 -0700 Jonathan Lemon wrote:
>> If attempting to flash the firmware with a blob of size 0,
>> the entire write loop is skipped and the uninitialized err
>> is returned.  Fix by setting to 0 first.
>> 
>> Also remove a now-unused error handling statement.
>> 
>> Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
>> ---
>> drivers/ptp/ptp_ocp.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>> 
>> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
>> index 92edf772feed..9b2ba06ebf97 100644
>> --- a/drivers/ptp/ptp_ocp.c
>> +++ b/drivers/ptp/ptp_ocp.c
>> @@ -763,7 +763,7 @@ ptp_ocp_devlink_flash(struct devlink *devlink, struct device *dev,
>>    size_t off, len, resid, wrote;
>>    struct erase_info erase;
>>    size_t base, blksz;
>> -    int err;
>> +    int err = 0;
>> 
>>    off = 0;
>>    base = bp->flash_start;
>> @@ -847,8 +847,6 @@ ptp_ocp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
>>                                   "loader",
>>                                   buf);
>>        }
>> -        if (err)
>> -            return err;
> 
> Looks like an accidental change, but it's mentioned in the commit log?

Yes, intentional, I spotted this NOP when fixing the compiler warning. 
— 
Jonathan
diff mbox series

Patch

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 92edf772feed..9b2ba06ebf97 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -763,7 +763,7 @@  ptp_ocp_devlink_flash(struct devlink *devlink, struct device *dev,
 	size_t off, len, resid, wrote;
 	struct erase_info erase;
 	size_t base, blksz;
-	int err;
+	int err = 0;
 
 	off = 0;
 	base = bp->flash_start;
@@ -847,8 +847,6 @@  ptp_ocp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
 							       "loader",
 							       buf);
 		}
-		if (err)
-			return err;
 	}
 
 	if (!bp->has_serial)