lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140602051447.GA30379@devel.8.8.4.4>
Date:	Mon, 2 Jun 2014 14:14:47 +0900
From:	Daeseok Youn <daeseok.youn@...il.com>
To:	lidza.louina@...il.com, gregkh@...uxfoundation.org
Cc:	markh@...pro.net, dan.carpenter@...cle.com,
	driverdev-devel@...uxdriverproject.org, devel@...verdev.osuosl.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH 2/6 RESEND V2] 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.

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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ