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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140620092150.GA23842@devel.8.8.4.4>
Date:	Fri, 20 Jun 2014 18:21:50 +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 V2] staging: dgap: make dgap_found_board() return a brd
 pointer

Make dgap_found_board() return a brd pointer and that brd pointer
assign to dgap_board[] in the end of the dgap_init_one().

Signed-off-by: Daeseok Youn <daeseok.youn@...il.com>
---
V2: change return value properly.
    update error handling, if one of functions in dgap_init_one() is
    failed, do not need to set dgap_board[] to NULL.

 drivers/staging/dgap/dgap.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 5c8e622..d4f80af 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -70,7 +70,8 @@ MODULE_SUPPORTED_DEVICE("dgap");
 
 static int dgap_start(void);
 static void dgap_init_globals(void);
-static int dgap_found_board(struct pci_dev *pdev, int id, int boardnum);
+static struct board_t *dgap_found_board(struct pci_dev *pdev, int id,
+					int boardnum);
 static void dgap_cleanup_board(struct board_t *brd);
 static void dgap_poll_handler(ulong dummy);
 static int dgap_init_pci(void);
@@ -582,11 +583,10 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (rc)
 		return -EIO;
 
-	rc = dgap_found_board(pdev, ent->driver_data, dgap_numboards);
-	if (rc)
-		return rc;
+	brd = dgap_found_board(pdev, ent->driver_data, dgap_numboards);
+	if (IS_ERR(brd))
+		return PTR_ERR(brd);
 
-	brd = dgap_board[dgap_numboards++];
 	rc = dgap_firmware_load(pdev, ent->driver_data, brd);
 	if (rc)
 		goto cleanup_brd;
@@ -617,6 +617,8 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	brd->state = BOARD_READY;
 	brd->dpastatus = BD_RUNNING;
 
+	dgap_board[dgap_numboards++] = brd;
+
 	return 0;
 
 tty_free:
@@ -630,7 +632,7 @@ free_flipbuf:
 cleanup_brd:
 	dgap_release_remap(brd);
 	kfree(brd);
-	dgap_board[--dgap_numboards] = NULL;
+
 	return rc;
 }
 
@@ -717,7 +719,8 @@ static void dgap_cleanup_board(struct board_t *brd)
  *
  * A board has been found, init it.
  */
-static int dgap_found_board(struct pci_dev *pdev, int id, int boardnum)
+static struct board_t *dgap_found_board(struct pci_dev *pdev, int id,
+					int boardnum)
 {
 	struct board_t *brd;
 	unsigned int pci_irq;
@@ -727,9 +730,7 @@ static int dgap_found_board(struct pci_dev *pdev, int id, int boardnum)
 	/* get the board structure and prep it */
 	brd = kzalloc(sizeof(struct board_t), GFP_KERNEL);
 	if (!brd)
-		return -ENOMEM;
-
-	dgap_board[boardnum] = brd;
+		return ERR_PTR(-ENOMEM);
 
 	/* store the info for the board we've found */
 	brd->magic = DGAP_BOARD_MAGIC;
@@ -828,13 +829,12 @@ static int dgap_found_board(struct pci_dev *pdev, int id, int boardnum)
 	pr_info("dgap: board %d: %s (rev %d), irq %ld\n",
 		boardnum, brd->name, brd->rev, brd->irq);
 
-	return 0;
+	return brd;
 
 free_brd:
 	kfree(brd);
-	dgap_board[boardnum] = NULL;
 
-	return ret;
+	return ERR_PTR(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