Commit 467132b0 authored by Daeseok Youn's avatar Daeseok Youn Committed by Greg Kroah-Hartman

staging: dgnc: kfree for board structure in dgnc_found_board()

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: default avatarDaeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b09f0cd5
...@@ -353,9 +353,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) ...@@ -353,9 +353,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
int rc = 0; int rc = 0;
/* get the board structure and prep it */ /* get the board structure and prep it */
dgnc_board[dgnc_num_boards] = kzalloc(sizeof(*brd), GFP_KERNEL); brd = kzalloc(sizeof(*brd), GFP_KERNEL);
brd = dgnc_board[dgnc_num_boards];
if (!brd) if (!brd)
return -ENOMEM; return -ENOMEM;
...@@ -411,7 +409,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) ...@@ -411,7 +409,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
if (!brd->membase) { if (!brd->membase) {
dev_err(&brd->pdev->dev, dev_err(&brd->pdev->dev,
"Card has no PCI IO resources, failing.\n"); "Card has no PCI IO resources, failing.\n");
return -ENODEV; rc = -ENODEV;
goto failed;
} }
brd->membase_end = pci_resource_end(pdev, 4); brd->membase_end = pci_resource_end(pdev, 4);
...@@ -502,7 +501,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) ...@@ -502,7 +501,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
default: default:
dev_err(&brd->pdev->dev, dev_err(&brd->pdev->dev,
"Didn't find any compatible Neo/Classic PCI boards.\n"); "Didn't find any compatible Neo/Classic PCI boards.\n");
return -ENXIO; rc = -ENXIO;
goto failed;
} }
/* /*
...@@ -539,14 +539,15 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) ...@@ -539,14 +539,15 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
wake_up_interruptible(&brd->state_wait); wake_up_interruptible(&brd->state_wait);
dgnc_board[dgnc_num_boards] = brd;
return 0; return 0;
failed: failed:
dgnc_tty_uninit(brd); dgnc_tty_uninit(brd);
brd->state = BOARD_FAILED; kfree(brd);
brd->dpastatus = BD_NOFEP;
return -ENXIO; return rc;
} }
static int dgnc_finalize_board_init(struct dgnc_board *brd) static int dgnc_finalize_board_init(struct dgnc_board *brd)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment