IB/hfi1: Fix for potential refcount leak in hfi1_open_file()
authorAlex Estrin <alex.estrin@intel.com>
Thu, 1 Feb 2018 18:43:58 +0000 (10:43 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Apr 2018 09:02:15 +0000 (11:02 +0200)
commit8f96d408a9547e2a814562796c6f7fac3e839332
treec21f7b0b5e9e4c1a40156fcab2f4f94ea1b6d4a4
parent5ceae7690f0d0575c730663ffd67493c9fa4e992
IB/hfi1: Fix for potential refcount leak in hfi1_open_file()

[ Upstream commit 2b1e7fe16124e86ee9242aeeee859c79a843e3a2 ]

The dd refcount is speculatively incremented prior to allocating
the fd memory with kzalloc(). If that kzalloc() failed the dd
refcount leaks.
Increment refcount on kzalloc success.

Fixes: e11ffbd57520 ("IB/hfi1: Do not free hfi1 cdev parent structure early")
Reviewed-by: Michael J Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Alex Estrin <alex.estrin@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/hw/hfi1/file_ops.c