In function mvs_pci_init(), the memory allocated by scsi_host_alloc() is not released on the error path that mvi, which holds the return value of mvs_pci_alloc(), is NULL. This will result in a memory leak bug.
Signed-off-by: Xidong Wang <wangxidong...@163.com> --- drivers/scsi/mvsas/mv_init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c index 8c91637..936b8ef 100644 --- a/drivers/scsi/mvsas/mv_init.c +++ b/drivers/scsi/mvsas/mv_init.c @@ -370,8 +370,10 @@ static struct mvs_info *mvs_pci_alloc(struct pci_dev *pdev, mvi = kzalloc(sizeof(*mvi) + (1L << mvs_chips[ent->driver_data].slot_width) * sizeof(struct mvs_slot_info), GFP_KERNEL); - if (!mvi) + if (!mvi) { + scsi_host_put(shost); return NULL; + } mvi->pdev = pdev; mvi->dev = &pdev->dev; -- 2.7.4