diff options
author | Daeseok Youn <daeseok.youn@gmail.com> | 2016-09-26 09:42:02 +0900 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-09-27 13:12:25 +0200 |
commit | 467132b029fedbffef2e252f2caff4f9dd9a59ff (patch) | |
tree | a3eed00a7f05a175e1724f18f31112d6e743a9a4 /drivers/staging/dgnc | |
parent | b09f0cd53f83f937a4e8b58298dbba981b72428b (diff) | |
download | talos-obmc-linux-467132b029fedbffef2e252f2caff4f9dd9a59ff.tar.gz talos-obmc-linux-467132b029fedbffef2e252f2caff4f9dd9a59ff.zip |
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: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/dgnc')
-rw-r--r-- | drivers/staging/dgnc/dgnc_driver.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index 58cebf425e36..0114e785a09c 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -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; @@ -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); @@ -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; } /* @@ -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) |