nvme: Fix wrong ndev->queues memset
PATCH 1/3 nvme: Fix wrong ndev->queues memset
memset() was given a sizeof(NVME_Q_NUM * sizeof(struct nvme_queue *) to clear, which is wrong.
---
drivers/nvme/nvme.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/nvme/nvme.c +1 -2
@@ -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) {
Signature · 1 line
2.9.2
PATCH 2/3 nvme: Fix potential sign extension issue in nvme_blk_rw()
"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".
---
drivers/nvme/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/nvme.c +1 -1
@@ -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; }
Signature · 1 line
2.9.2
PATCH 2/3 nvme: Fix potential sign extension issue in nvme_blk_rw()
Quoted 10 lines · Bin Meng
"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 than0x7FFFFFFF, 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 <[email protected]>
Signature · 8 lines
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>
PATCH 2/3 nvme: Fix potential sign extension issue in nvme_blk_rw()
In reply to Bin MengQuoted 11 lines · Bin Meng
"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 than0x7FFFFFFF, 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 <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
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>
PATCH 3/3 nvme: Remove dead codes in nvme_setup_io_queues()
In reply to Bin MengExecution cannot reach this statement: "nr_io_queues = result;"
---
drivers/nvme/nvme.c | 3 --- 1 file changed, 3 deletions(-)
drivers/nvme/nvme.c +0 -3
@@ -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 */
Signature · 1 line
2.9.2
PATCH 3/3 nvme: Remove dead codes in nvme_setup_io_queues()
Quoted 4 lines · Bin Meng
Execution cannot reach this statement: "
nr_io_queues= result;"Reported-by Coverity (CID: 166731)Signed-off-by Bin Meng <[email protected]>
Signature · 8 lines
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>
PATCH 3/3 nvme: Remove dead codes in nvme_setup_io_queues()
In reply to Bin MengQuoted 5 lines · Bin Meng
Execution cannot reach this statement: "
nr_io_queues= result;"Reported-by Coverity (CID: 166731)Signed-off-by Bin Meng <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
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>
PATCH 1/3 nvme: Fix wrong ndev->queues memset
In reply to Bin MengQuoted 5 lines · Bin Meng
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 <[email protected]>
Signature · 8 lines
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>
PATCH 1/3 nvme: Fix wrong ndev->queues memset
In reply to Bin MengQuoted 6 lines · Bin Meng
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 <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
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>