Skip to content

Commit

Permalink
staging: dgnc: kfree for board structure in dgnc_found_board()
Browse files Browse the repository at this point in the history
The board structure should be freed when any function was failed
in dgnc_found_board(). And the board strucure will be stored
into dgnc_board array when the dgnc_found_board() function has no error.

Signed-off-by: Daeseok Youn <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
daeseokyoun authored and gregkh committed Sep 27, 2016
1 parent b09f0cd commit 467132b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions drivers/staging/dgnc/dgnc_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
int rc = 0;

/* get the board structure and prep it */
dgnc_board[dgnc_num_boards] = kzalloc(sizeof(*brd), GFP_KERNEL);
brd = dgnc_board[dgnc_num_boards];

brd = kzalloc(sizeof(*brd), GFP_KERNEL);
if (!brd)
return -ENOMEM;

Expand Down Expand Up @@ -411,7 +409,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
if (!brd->membase) {
dev_err(&brd->pdev->dev,
"Card has no PCI IO resources, failing.\n");
return -ENODEV;
rc = -ENODEV;
goto failed;
}

brd->membase_end = pci_resource_end(pdev, 4);
Expand Down Expand Up @@ -502,7 +501,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
default:
dev_err(&brd->pdev->dev,
"Didn't find any compatible Neo/Classic PCI boards.\n");
return -ENXIO;
rc = -ENXIO;
goto failed;
}

/*
Expand Down Expand Up @@ -539,14 +539,15 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)

wake_up_interruptible(&brd->state_wait);

dgnc_board[dgnc_num_boards] = brd;

return 0;

failed:
dgnc_tty_uninit(brd);
brd->state = BOARD_FAILED;
brd->dpastatus = BD_NOFEP;
kfree(brd);

return -ENXIO;
return rc;
}

static int dgnc_finalize_board_init(struct dgnc_board *brd)
Expand Down

0 comments on commit 467132b

Please sign in to comment.