mlx5: Fix for potential memory leaks.

Make sure allocated data gets freed in error cases.

Submitted by:   hselasky@
Approved by:    hselasky (mentor)
MFC after:      1 week
Sponsored by:   Mellanox Technologies
This commit is contained in:
Slava Shwartsman 2018-12-05 13:41:37 +00:00
parent 07b624ed71
commit 3b21d18587
3 changed files with 5 additions and 3 deletions

View File

@ -1601,9 +1601,10 @@ static char *get_dest_name(struct mlx5_flow_destination *dest)
case MLX5_FLOW_CONTEXT_DEST_TYPE_TIR:
snprintf(name, 20, "dest_%s_%u", "tir", dest->tir_num);
return name;
default:
kfree(name);
return NULL;
}
return NULL;
}
/* assumed fg is locked */

View File

@ -153,6 +153,7 @@ mlx5_fwp_alloc(struct mlx5_core_dev *dev, gfp_t flags, unsigned num)
bus_dmamem_free(dev->cmd.dma_tag, fwp[x].virt_addr, fwp[x].dma_map);
}
sx_xunlock(&dev->cmd.dma_sx);
kfree(fwp);
return (NULL);
}

View File

@ -1597,8 +1597,8 @@ int mlx5_query_vport_counter(struct mlx5_core_dev *dev,
err = mlx5_cmd_exec(dev, in, in_sz, out, out_size);
kvfree(in);
ex:
kvfree(in);
return err;
}
EXPORT_SYMBOL_GPL(mlx5_query_vport_counter);