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: <1425918578-10223-1-git-send-email-giedrius.statkevicius@gmail.com>
Date:	Mon,  9 Mar 2015 18:29:38 +0200
From:	Giedrius Statkevičius 
	<giedrius.statkevicius@...il.com>
To:	lidza.louina@...il.com, markh@...pro.net
Cc:	gregkh@...uxfoundation.org, driverdev-devel@...uxdriverproject.org,
	devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
	dan.carpenter@...cle.com,
	Giedrius Statkevičius 
	<giedrius.statkevicius@...il.com>
Subject: [PATCH v2] dgnc: Don't save boards in memory that have failed to initialize

Remove BOARD_FAILED and don't save dgnc_boards which failed to
initialize.

Assign the result of kzalloc() to brd in dgnc_found_board() and only put
it in the dgnc_Board[] if it successfully initializes. Also, remove
BOARD_FAILED enum and all ifs that check for it. Finally, remove one
final place where state was set to BOARD_FAILED which was even redundant
before this patch.

Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@...il.com>
---
v2: Remove "brd = dgnc_Board[dgnc_NumBoards];" line which I forgot to do
in the first version

 drivers/staging/dgnc/dgnc_driver.c | 20 ++------------------
 drivers/staging/dgnc/dgnc_driver.h |  3 +--
 drivers/staging/dgnc/dgnc_mgmt.c   |  5 +----
 drivers/staging/dgnc/dgnc_tty.c    |  8 --------
 4 files changed, 4 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index fa1ee79..075727d 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -401,8 +401,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 	unsigned long flags;
 
 	/* get the board structure and prep it */
-	dgnc_Board[dgnc_NumBoards] = kzalloc(sizeof(*brd), GFP_KERNEL);
-	brd = dgnc_Board[dgnc_NumBoards];
+	brd = kzalloc(sizeof(*brd), GFP_KERNEL);
 
 	if (!brd)
 		return -ENOMEM;
@@ -574,17 +573,12 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 	if (rc < 0) {
 		dgnc_tty_uninit(brd);
 		pr_err(DRVSTR ": Can't register tty devices (%d)\n", rc);
-		brd->state = BOARD_FAILED;
-		brd->dpastatus = BD_NOFEP;
 		goto failed;
 	}
 
 	rc = dgnc_finalize_board_init(brd);
 	if (rc < 0) {
 		pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc);
-		brd->state = BOARD_FAILED;
-		brd->dpastatus = BD_NOFEP;
-
 		goto failed;
 	}
 
@@ -592,9 +586,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 	if (rc < 0) {
 		dgnc_tty_uninit(brd);
 		pr_err(DRVSTR ": Can't init tty devices (%d)\n", rc);
-		brd->state = BOARD_FAILED;
-		brd->dpastatus = BD_NOFEP;
-
 		goto failed;
 	}
 
@@ -624,6 +615,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 	brd->flipbuf = kzalloc(MYFLIPLEN, GFP_KERNEL);
 
 	wake_up_interruptible(&brd->state_wait);
+	dgnc_Board[dgnc_NumBoards] = brd;
 
 	return 0;
 
@@ -648,8 +640,6 @@ static int dgnc_finalize_board_init(struct dgnc_board *brd)
 		if (rc) {
 			dev_err(&brd->pdev->dev,
 				"Failed to hook IRQ %d\n", brd->irq);
-			brd->state = BOARD_FAILED;
-			brd->dpastatus = BD_NOFEP;
 			rc = -ENODEV;
 		}
 	}
@@ -708,12 +698,6 @@ static void dgnc_poll_handler(ulong dummy)
 
 		spin_lock_irqsave(&brd->bd_lock, flags);
 
-		/* If board is in a failed state, don't bother scheduling a tasklet */
-		if (brd->state == BOARD_FAILED) {
-			spin_unlock_irqrestore(&brd->bd_lock, flags);
-			continue;
-		}
-
 		/* Schedule a poll helper task */
 		tasklet_schedule(&brd->helper_tasklet);
 
diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h
index 734bdc2..9f0d97b 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -107,8 +107,7 @@ enum {
  * All the possible states the board can be while booting up.
  */
 enum {
-	BOARD_FAILED = 0,
-	BOARD_FOUND,
+	BOARD_FOUND = 0,
 	BOARD_READY
 };
 
diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
index 5544a8e..8c3a1bf 100644
--- a/drivers/staging/dgnc/dgnc_mgmt.c
+++ b/drivers/staging/dgnc/dgnc_mgmt.c
@@ -168,10 +168,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		di.info_ioport = 0;
 		di.info_physaddr = (ulong) dgnc_Board[brd]->membase;
 		di.info_physsize = (ulong) dgnc_Board[brd]->membase - dgnc_Board[brd]->membase_end;
-		if (dgnc_Board[brd]->state != BOARD_FAILED)
-			di.info_nports = dgnc_Board[brd]->nasync;
-		else
-			di.info_nports = 0;
+		di.info_nports = dgnc_Board[brd]->nasync;
 
 		spin_unlock_irqrestore(&dgnc_Board[brd]->bd_lock, flags);
 
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 8179342..570eb7e 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1253,14 +1253,6 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc
 
 		sleep_on_un_flags = 0;
 
-		/*
-		 * If board has failed somehow during our sleep, bail with error.
-		 */
-		if (ch->ch_bd->state == BOARD_FAILED) {
-			retval = -ENXIO;
-			break;
-		}
-
 		/* If tty was hung up, break out of loop and set error. */
 		if (tty_hung_up_p(file)) {
 			retval = -EAGAIN;
-- 
2.3.2

--
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