All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/3] nvme: Fix wrong ndev->queues memset
@ 2017-09-02 15:15 Bin Meng
  2017-09-02 15:15 ` [U-Boot] [PATCH 2/3] nvme: Fix potential sign extension issue in nvme_blk_rw() Bin Meng
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Bin Meng @ 2017-09-02 15:15 UTC (permalink / raw)
  To: u-boot

memset() was given a sizeof(NVME_Q_NUM * sizeof(struct nvme_queue *)
to clear, which is wrong.

Reported-by: Coverity (CID: 166729)
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 drivers/nvme/nvme.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
index ec32d0d..4448754 100644
--- a/drivers/nvme/nvme.c
+++ b/drivers/nvme/nvme.c
@@ -791,8 +791,7 @@ static int nvme_probe(struct udevice *udev)
 		printf("Error: %s: Out of memory!\n", udev->name);
 		goto free_nvme;
 	}
-	memset(ndev->queues, 0,
-	       sizeof(NVME_Q_NUM * sizeof(struct nvme_queue *)));
+	memset(ndev->queues, 0, NVME_Q_NUM * sizeof(struct nvme_queue *));
 
 	ndev->prp_pool = malloc(MAX_PRP_POOL);
 	if (!ndev->prp_pool) {
-- 
2.9.2

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

* [U-Boot] [PATCH 2/3] nvme: Fix potential sign extension issue in nvme_blk_rw()
  2017-09-02 15:15 [U-Boot] [PATCH 1/3] nvme: Fix wrong ndev->queues memset Bin Meng
@ 2017-09-02 15:15 ` Bin Meng
  2017-09-02 15:23   ` Tom Rini
  2017-09-04  0:42   ` [U-Boot] [U-Boot, " Tom Rini
  2017-09-02 15:15 ` [U-Boot] [PATCH 3/3] nvme: Remove dead codes in nvme_setup_io_queues() Bin Meng
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 9+ messages in thread
From: Bin Meng @ 2017-09-02 15:15 UTC (permalink / raw)
  To: u-boot

"lbas" with type "u16" (16 bits, unsigned) is promoted in
"lbas << ns->lba_shift" to type "int" (32 bits, signed), then
sign-extended to type "unsigned long long" (64 bits, unsigned).
If "lbas << ns->lba_shift" is greater than 0x7FFFFFFF, the upper
bits of the result will all be 1.

Fix it by casting "lbas" to "u32".

Reported-by: Coverity (CID: 166730)
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 drivers/nvme/nvme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
index 4448754..59d54eb 100644
--- a/drivers/nvme/nvme.c
+++ b/drivers/nvme/nvme.c
@@ -723,7 +723,7 @@ static ulong nvme_blk_rw(struct udevice *udev, lbaint_t blknr,
 				&c, NULL, IO_TIMEOUT);
 		if (status)
 			break;
-		temp_len -= lbas << ns->lba_shift;
+		temp_len -= (u32)lbas << ns->lba_shift;
 		buffer += lbas << ns->lba_shift;
 	}
 
-- 
2.9.2

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

* [U-Boot] [PATCH 3/3] nvme: Remove dead codes in nvme_setup_io_queues()
  2017-09-02 15:15 [U-Boot] [PATCH 1/3] nvme: Fix wrong ndev->queues memset Bin Meng
  2017-09-02 15:15 ` [U-Boot] [PATCH 2/3] nvme: Fix potential sign extension issue in nvme_blk_rw() Bin Meng
@ 2017-09-02 15:15 ` Bin Meng
  2017-09-02 15:23   ` Tom Rini
  2017-09-04  0:42   ` [U-Boot] [U-Boot, " Tom Rini
  2017-09-02 15:23 ` [U-Boot] [PATCH 1/3] nvme: Fix wrong ndev->queues memset Tom Rini
  2017-09-04  0:42 ` [U-Boot] [U-Boot,1/3] " Tom Rini
  3 siblings, 2 replies; 9+ messages in thread
From: Bin Meng @ 2017-09-02 15:15 UTC (permalink / raw)
  To: u-boot

Execution cannot reach this statement: "nr_io_queues = result;"

Reported-by: Coverity (CID: 166731)
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 drivers/nvme/nvme.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
index 59d54eb..1c3519b 100644
--- a/drivers/nvme/nvme.c
+++ b/drivers/nvme/nvme.c
@@ -562,9 +562,6 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
 	if (result <= 0)
 		return result;
 
-	if (result < nr_io_queues)
-		nr_io_queues = result;
-
 	dev->max_qid = nr_io_queues;
 
 	/* Free previously allocated queues */
-- 
2.9.2

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

* [U-Boot] [PATCH 1/3] nvme: Fix wrong ndev->queues memset
  2017-09-02 15:15 [U-Boot] [PATCH 1/3] nvme: Fix wrong ndev->queues memset Bin Meng
  2017-09-02 15:15 ` [U-Boot] [PATCH 2/3] nvme: Fix potential sign extension issue in nvme_blk_rw() Bin Meng
  2017-09-02 15:15 ` [U-Boot] [PATCH 3/3] nvme: Remove dead codes in nvme_setup_io_queues() Bin Meng
@ 2017-09-02 15:23 ` Tom Rini
  2017-09-04  0:42 ` [U-Boot] [U-Boot,1/3] " Tom Rini
  3 siblings, 0 replies; 9+ messages in thread
From: Tom Rini @ 2017-09-02 15:23 UTC (permalink / raw)
  To: u-boot

On Sat, Sep 02, 2017 at 08:15:35AM -0700, Bin Meng wrote:

> memset() was given a sizeof(NVME_Q_NUM * sizeof(struct nvme_queue *)
> to clear, which is wrong.
> 
> Reported-by: Coverity (CID: 166729)
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170902/017470b3/attachment.sig>

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

* [U-Boot] [PATCH 2/3] nvme: Fix potential sign extension issue in nvme_blk_rw()
  2017-09-02 15:15 ` [U-Boot] [PATCH 2/3] nvme: Fix potential sign extension issue in nvme_blk_rw() Bin Meng
@ 2017-09-02 15:23   ` Tom Rini
  2017-09-04  0:42   ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 9+ messages in thread
From: Tom Rini @ 2017-09-02 15:23 UTC (permalink / raw)
  To: u-boot

On Sat, Sep 02, 2017 at 08:15:36AM -0700, Bin Meng wrote:

> "lbas" with type "u16" (16 bits, unsigned) is promoted in
> "lbas << ns->lba_shift" to type "int" (32 bits, signed), then
> sign-extended to type "unsigned long long" (64 bits, unsigned).
> If "lbas << ns->lba_shift" is greater than 0x7FFFFFFF, the upper
> bits of the result will all be 1.
> 
> Fix it by casting "lbas" to "u32".
> 
> Reported-by: Coverity (CID: 166730)
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170902/ea786043/attachment.sig>

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

* [U-Boot] [PATCH 3/3] nvme: Remove dead codes in nvme_setup_io_queues()
  2017-09-02 15:15 ` [U-Boot] [PATCH 3/3] nvme: Remove dead codes in nvme_setup_io_queues() Bin Meng
@ 2017-09-02 15:23   ` Tom Rini
  2017-09-04  0:42   ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 9+ messages in thread
From: Tom Rini @ 2017-09-02 15:23 UTC (permalink / raw)
  To: u-boot

On Sat, Sep 02, 2017 at 08:15:37AM -0700, Bin Meng wrote:

> Execution cannot reach this statement: "nr_io_queues = result;"
> 
> Reported-by: Coverity (CID: 166731)
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170902/b3bd3b16/attachment.sig>

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

* [U-Boot] [U-Boot,1/3] nvme: Fix wrong ndev->queues memset
  2017-09-02 15:15 [U-Boot] [PATCH 1/3] nvme: Fix wrong ndev->queues memset Bin Meng
                   ` (2 preceding siblings ...)
  2017-09-02 15:23 ` [U-Boot] [PATCH 1/3] nvme: Fix wrong ndev->queues memset Tom Rini
@ 2017-09-04  0:42 ` Tom Rini
  3 siblings, 0 replies; 9+ messages in thread
From: Tom Rini @ 2017-09-04  0:42 UTC (permalink / raw)
  To: u-boot

On Sat, Sep 02, 2017 at 08:15:35AM -0700, Bin Meng wrote:

> memset() was given a sizeof(NVME_Q_NUM * sizeof(struct nvme_queue *)
> to clear, which is wrong.
> 
> Reported-by: Coverity (CID: 166729)
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170903/d862bdbb/attachment.sig>

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

* [U-Boot] [U-Boot, 2/3] nvme: Fix potential sign extension issue in nvme_blk_rw()
  2017-09-02 15:15 ` [U-Boot] [PATCH 2/3] nvme: Fix potential sign extension issue in nvme_blk_rw() Bin Meng
  2017-09-02 15:23   ` Tom Rini
@ 2017-09-04  0:42   ` Tom Rini
  1 sibling, 0 replies; 9+ messages in thread
From: Tom Rini @ 2017-09-04  0:42 UTC (permalink / raw)
  To: u-boot

On Sat, Sep 02, 2017 at 08:15:36AM -0700, Bin Meng wrote:

> "lbas" with type "u16" (16 bits, unsigned) is promoted in
> "lbas << ns->lba_shift" to type "int" (32 bits, signed), then
> sign-extended to type "unsigned long long" (64 bits, unsigned).
> If "lbas << ns->lba_shift" is greater than 0x7FFFFFFF, the upper
> bits of the result will all be 1.
> 
> Fix it by casting "lbas" to "u32".
> 
> Reported-by: Coverity (CID: 166730)
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170903/8cb6da61/attachment.sig>

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

* [U-Boot] [U-Boot, 3/3] nvme: Remove dead codes in nvme_setup_io_queues()
  2017-09-02 15:15 ` [U-Boot] [PATCH 3/3] nvme: Remove dead codes in nvme_setup_io_queues() Bin Meng
  2017-09-02 15:23   ` Tom Rini
@ 2017-09-04  0:42   ` Tom Rini
  1 sibling, 0 replies; 9+ messages in thread
From: Tom Rini @ 2017-09-04  0:42 UTC (permalink / raw)
  To: u-boot

On Sat, Sep 02, 2017 at 08:15:37AM -0700, Bin Meng wrote:

> Execution cannot reach this statement: "nr_io_queues = result;"
> 
> Reported-by: Coverity (CID: 166731)
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170903/f790999c/attachment.sig>

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

end of thread, other threads:[~2017-09-04  0:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-02 15:15 [U-Boot] [PATCH 1/3] nvme: Fix wrong ndev->queues memset Bin Meng
2017-09-02 15:15 ` [U-Boot] [PATCH 2/3] nvme: Fix potential sign extension issue in nvme_blk_rw() Bin Meng
2017-09-02 15:23   ` Tom Rini
2017-09-04  0:42   ` [U-Boot] [U-Boot, " Tom Rini
2017-09-02 15:15 ` [U-Boot] [PATCH 3/3] nvme: Remove dead codes in nvme_setup_io_queues() Bin Meng
2017-09-02 15:23   ` Tom Rini
2017-09-04  0:42   ` [U-Boot] [U-Boot, " Tom Rini
2017-09-02 15:23 ` [U-Boot] [PATCH 1/3] nvme: Fix wrong ndev->queues memset Tom Rini
2017-09-04  0:42 ` [U-Boot] [U-Boot,1/3] " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.