staging: dgap: unwind on error in dgap_found_board()
PATCH RESEND v2 2/6 staging: dgap: unwind on error in dgap_found_board()
Adds a label for "kfree(brd)". And also remove
a state value as BOARD_FAILED in brd when dgap_do_remap() is failed. Because "brd" will free after failure.
---
RESEND: this patch is included into newly series of patches.
V2: add "Reviewed-by" line in change log.
drivers/staging/dgap/dgap.c | 19 ++++++++++++++----- 1 files changed, 14 insertions(+), 5 deletions(-)
drivers/staging/dgap/dgap.c +14 -5
@@ -673,6 +673,7 @@ static int dgap_found_board(struct pci_dev *pdev, int id)struct board_t *brd;unsigned int pci_irq;int i; +int ret;/* get the board structure and prep it */ brd =kzalloc (sizeof (struct board_t ),GFP_KERNEL );
@@ -728,8 +729,10 @@ static int dgap_found_board(struct pci_dev *pdev, int id) brd->membase_end =pci_resource_end (pdev,0 ); } -if (!brd->membase) -return -ENODEV ; +if (!brd->membase) { + ret = -ENODEV ; + goto free_brd; + }if (brd->membase &1 ) brd->membase &= ~3 ;
@@ -770,14 +773,20 @@ static int dgap_found_board(struct pci_dev *pdev, int id)tasklet_init (&brd->helper_tasklet, dgap_poll_tasklet, (unsigned long ) brd); - i =dgap_do_remap (brd); -if (i) - brd->state =BOARD_FAILED ; + ret =dgap_do_remap (brd); +if (ret) + goto free_brd;pr_info ("dgap: board %d: %s (rev %d), irq %ld\n" , dgap_numboards, brd->name, brd->rev, brd->irq);return 0 ; + +free_brd: +kfree (brd); + dgap_board[dgap_numboards] =NULL ; + +return ret; }
Signature · 1 line
1.7.1
Quoted 9 lines · Daeseok Youn
Adds a label for "kfree(brd)". And also remove
a state value asBOARD_FAILEDin brd whendgap_do_remap()is failed. Because "brd" will free after failure.Signed-off-by Daeseok Youn <[email protected]>Reviewed-by Dan Carpenter <[email protected]>---
RESEND: this patch is included into newly series of patches.
V2: add "Reviewed-by" line in change log.
Don't worry about this stuff, Greg's scripts pick it up, or if they don't, I don't care.
regards,
dan carpenter
2014-06-02 17:00 GMT+09:00 Dan Carpenter <[email protected]>:
Quoted 5 lines · Daeseok Youn
Quoted 4 lines
Adds a label for "kfree(brd)". And also remove
a state value asBOARD_FAILEDin brd whendgap_do_remap()is failed. Because "brd" will free after failure.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Daeseok Youn <[email protected]>Reviewed-by Dan Carpenter <[email protected]>---
RESEND: this patch is included into newly series of patches.
V2: add "Reviewed-by" line in change log.Don't worry about this stuff, Greg's scripts pick it up, or if they don't, I don't care.
OK. I got that.
Thanks.
Daeseok Youn.
Quoted 4 lines
regards,
dan carpenter