> -----Original Message----- > From: zhengbin <zhengbin13@xxxxxxxxxx> > Sent: Monday, August 19, 2019 9:58 AM > To: dledford@xxxxxxxxxx; jgg@xxxxxxxx; leon@xxxxxxxxxx; Parav Pandit > <parav@xxxxxxxxxxxx>; swise@xxxxxxxxxxxxxxxxxxxxx; Daniel Jurgens > <danielj@xxxxxxxxxxxx>; Danit Goldberg <danitg@xxxxxxxxxxxx>; > willy@xxxxxxxxxxxxx; linux-rdma@xxxxxxxxxxxxxxx > Cc: zhengbin13@xxxxxxxxxx; yi.zhang@xxxxxxxxxx > Subject: [PATCH] RDMA/cma: fix null-ptr-deref Read in cma_cleanup > > In cma_init, if cma_configfs_init fails, need to free the previously memory and > return fail, otherwise will trigger null-ptr-deref Read in cma_cleanup. > > cma_cleanup > cma_configfs_exit > configfs_unregister_subsystem > > Fixes: 045959db65c6 ("IB/cma: Add configfs for rdma_cm") > Reported-by: Hulk Robot <hulkci@xxxxxxxxxx> > Signed-off-by: zhengbin <zhengbin13@xxxxxxxxxx> > --- > drivers/infiniband/core/cma.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c > index 19f1730..a68d0cc 100644 > --- a/drivers/infiniband/core/cma.c > +++ b/drivers/infiniband/core/cma.c > @@ -4724,10 +4724,14 @@ static int __init cma_init(void) > if (ret) > goto err; > > - cma_configfs_init(); > + ret = cma_configfs_init(); > + if (ret) > + goto err_ib; > > return 0; > > +err_ib: > + ib_unregister_client(&cma_client); > err: > unregister_netdevice_notifier(&cma_nb); > ib_sa_unregister_client(&sa_client); > -- > 2.7.4 Reviewed-by: Parav Pandit <parav@xxxxxxxxxxxx>