Re: [rdma-rc 08/14] RDMA/mlx4: Avoid potential derefence warning

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

 



On Mon, Jul 31, 2017 at 10:09:18AM +0300, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@xxxxxxxxxxxx>
>
> The smatch complains about possible dereference, it is unclear from
> source how it can occur, since in case of failure to find/allocate
> group, the acquire_group() will return error.
>
> Avoid the following error, by changing IS_ERR() to be IS_ERR_OR_NULL().
>
> drivers/infiniband/hw/mlx4/mcg.c:964 mlx4_ib_mcg_multiplex_handler() error:
> 	potential null dereference 'group'.  (acquire_group returns null)
>
> Fixes: b9c5d6a64358 ("IB/mlx4: Add multicast group (MCG) paravirtualization for SR-IOV")
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> ---
>  drivers/infiniband/hw/mlx4/mcg.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Hi Dan,

Bart [1] and me both believe that smatch tool is incorrectly reported error.
Do you think that the tool should be fixed?

Thanks

[1] http://marc.info/?l=linux-rdma&m=150151394813006&w=2

> diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
> index b73f89700ef9..9c26a6837c62 100644
> --- a/drivers/infiniband/hw/mlx4/mcg.c
> +++ b/drivers/infiniband/hw/mlx4/mcg.c
> @@ -956,7 +956,7 @@ int mlx4_ib_mcg_multiplex_handler(struct ib_device *ibdev, int port,
>  		mutex_lock(&ctx->mcg_table_lock);
>  		group = acquire_group(ctx, &rec->mgid, may_create, GFP_KERNEL);
>  		mutex_unlock(&ctx->mcg_table_lock);
> -		if (IS_ERR(group)) {
> +		if (IS_ERR_OR_NULL(group)) {
>  			kfree(req);
>  			return PTR_ERR(group);
>  		}
> --
> 2.13.3
>

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux