public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/6 RESEND V2] staging: dgap: unwind on error in dgap_found_board()
@ 2014-06-02  5:14 Daeseok Youn
  2014-06-02  8:00 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Daeseok Youn @ 2014-06-02  5:14 UTC (permalink / raw)
  To: lidza.louina, gregkh
  Cc: markh, dan.carpenter, driverdev-devel, devel, linux-kernel

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.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
---
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(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index af78f6f..5556a6e 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -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;
 }
 
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/6 RESEND V2] staging: dgap: unwind on error in dgap_found_board()
  2014-06-02  5:14 [PATCH 2/6 RESEND V2] staging: dgap: unwind on error in dgap_found_board() Daeseok Youn
@ 2014-06-02  8:00 ` Dan Carpenter
  2014-06-02  9:39   ` DaeSeok Youn
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2014-06-02  8:00 UTC (permalink / raw)
  To: Daeseok Youn
  Cc: lidza.louina, gregkh, markh, driverdev-devel, devel, linux-kernel

On Mon, Jun 02, 2014 at 02:14:47PM +0900, Daeseok Youn wrote:
> 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.
> 
> Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/6 RESEND V2] staging: dgap: unwind on error in dgap_found_board()
  2014-06-02  8:00 ` Dan Carpenter
@ 2014-06-02  9:39   ` DaeSeok Youn
  0 siblings, 0 replies; 3+ messages in thread
From: DaeSeok Youn @ 2014-06-02  9:39 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Lidza Louina, Greg KH, Mark Hounschell, driverdev-devel, devel,
	linux-kernel

2014-06-02 17:00 GMT+09:00 Dan Carpenter <dan.carpenter@oracle.com>:
> On Mon, Jun 02, 2014 at 02:14:47PM +0900, Daeseok Youn wrote:
>> 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.
>>
>> Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
>> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
>> ---
>> 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.
>
> regards,
> dan carpenter
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-02  9:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-02  5:14 [PATCH 2/6 RESEND V2] staging: dgap: unwind on error in dgap_found_board() Daeseok Youn
2014-06-02  8:00 ` Dan Carpenter
2014-06-02  9:39   ` DaeSeok Youn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox