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)
committerJason Gunthorpe <jgg@mellanox.com>
Thu, 1 Feb 2018 22:24:32 +0000 (15:24 -0700)
commit2b1e7fe16124e86ee9242aeeee859c79a843e3a2
tree233de075dfe127bfcdc5faec36f5aa69d221381d
parent473291b3ea0e1df81f7abf13b8ab4b98a346df5e
IB/hfi1: Fix for potential refcount leak in hfi1_open_file()

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>
drivers/infiniband/hw/hfi1/file_ops.c