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: <1430489763-18417-1-git-send-email-hofrat@osadl.org>
Date:	Fri,  1 May 2015 16:16:01 +0200
From:	Nicholas Mc Guire <hofrat@...dl.org>
To:	David Woodhouse <dwmw2@...radead.org>
Cc:	Brian Norris <computersforpeace@...il.com>,
	Vinod Koul <vinod.koul@...el.com>,
	Laurent Pinchart <laurent.pinchart+renesas@...asonboard.com>,
	Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>,
	Wolfram Sang <wsa@...-dreams.de>,
	Arnd Bergmann <arnd@...db.de>, linux-mtd@...ts.infradead.org,
	linux-kernel@...r.kernel.org, Nicholas Mc Guire <hofrat@...dl.org>
Subject: [PATCH 1/3] mtd: sh_flctl: fixup wait_for_completion_timeout return handling

wait_for_completion_timeout() returns unsigned long not int so the check 
for <= should be == and the type unsigned long. This fixes up the return 
value handling and returns -ETIMEDOUT on timeout rather than 0 and 1 on 
on success rather than a more or less random remaining number of jiffies.

Signed-off-by: Nicholas Mc Guire <hofrat@...dl.org>
---

call sites:
read_fiforeg,write_ec_fiforeg assume > 0 == success
and the comment in flctl_dma_fifo0_transfe states
        /* ret > 0 is success */
        return ret;
since it is only checking for > 0 in the call-sites
returning -ETIMEDOUT should be fine.

Patch was compile tested with ap325rxa_defconfig (implies
CONFIG_MTD_NAND_SH_FLCTL=y)

Patch is against 4.1-rc1 (localversion-next is -next-20150501)

 drivers/mtd/nand/sh_flctl.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c
index c3ce81c..4450864 100644
--- a/drivers/mtd/nand/sh_flctl.c
+++ b/drivers/mtd/nand/sh_flctl.c
@@ -354,6 +354,7 @@ static int flctl_dma_fifo0_transfer(struct sh_flctl *flctl, unsigned long *buf,
 	dma_cookie_t cookie = -EINVAL;
 	uint32_t reg;
 	int ret;
+	unsigned long time_left;
 
 	if (dir == DMA_FROM_DEVICE) {
 		chan = flctl->chan_fifo0_rx;
@@ -388,14 +389,16 @@ static int flctl_dma_fifo0_transfer(struct sh_flctl *flctl, unsigned long *buf,
 		goto out;
 	}
 
-	ret =
+	time_left =
 	wait_for_completion_timeout(&flctl->dma_complete,
 				msecs_to_jiffies(3000));
 
-	if (ret <= 0) {
+	if (time_left == 0) {
 		dmaengine_terminate_all(chan);
 		dev_err(&flctl->pdev->dev, "wait_for_completion_timeout\n");
-	}
+		ret = -ETIMEDOUT;
+	} else
+		ret = 1;	/* completion succeeded */
 
 out:
 	reg = readl(FLINTDMACR(flctl));
-- 
1.7.10.4

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