Re: [v2] RDMA/iwpm: Fix uninitialized error code in iwpm_send_mapinfo()

From: Jason Gunthorpe
Date: Wed Dec 13 2017 - 13:19:50 EST


On Wed, Nov 29, 2017 at 09:47:33AM +0100, Geert Uytterhoeven wrote:
> With gcc-4.1.2:
>
> drivers/infiniband/core/iwpm_util.c: In function âiwpm_send_mapinfoâ:
> drivers/infiniband/core/iwpm_util.c:647: warning: âretâ may be used uninitialized in this function
>
> Indeed, if nl_client is not found in any of the scanned has buckets, ret
> will be used uninitialized.
>
> Preinitialize ret to -EINVAL to fix this.
>
> Fixes: 30dc5e63d6a5ad24 ("RDMA/core: Add support for iWARP Port Mapper user space service")
> Signed-off-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
> Reviewed-by: Tatyana Nikolova <tatyana.e.nikolova@xxxxxxxxx>
> v2:
> - Use -EINVAL instead of zero,
> - Move the preinitialization to just before the loop, to catach future
> early offenders,
> - Drop RFC state.
> drivers/infiniband/core/iwpm_util.c | 1 +
> 1 file changed, 1 insertion(+)

Thanks applied to -next.

Jason