diff mbox

RDMA/hns: ensure for-loop actually iterates and free's buffers

Message ID 20180326151018.21066-1-colin.king@canonical.com (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show

Commit Message

Colin King March 26, 2018, 3:10 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The current for-loop zeros variable i and only loops once, hence
not all the buffers are free'd.  Fix this by setting i correctly.

Detected by CoverityScan, CID#1463415 ("Operands don't affect result")

Fixes: a5073d6054f7 ("RDMA/hns: Add eq support of hip08")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Yixian Liu March 27, 2018, 7:14 a.m. UTC | #1
On 2018/3/26 23:10, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The current for-loop zeros variable i and only loops once, hence
> not all the buffers are free'd.  Fix this by setting i correctly.

Hi Colin,

Thank you very much for this patch! It's a typo when I prepared the patch set.

Reviewed-by: Yixian Liu <liuyixian@huawei.com>

> 
> Detected by CoverityScan, CID#1463415 ("Operands don't affect result")
> 
> Fixes: a5073d6054f7 ("RDMA/hns: Add eq support of hip08")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> index 684c2d1a0ed0..8b84ab7800d8 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> @@ -4391,7 +4391,7 @@ static int hns_roce_mhop_alloc_eq(struct hns_roce_dev *hr_dev,
>  	eq->l0_dma = 0;
>  
>  	if (mhop_num == 1)
> -		for (i -= i; i >= 0; i--)
> +		for (i -= 1; i >= 0; i--)
>  			dma_free_coherent(dev, buf_chk_sz, eq->buf[i],
>  					  eq->buf_dma[i]);
>  	else if (mhop_num == 2) {
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jason Gunthorpe March 27, 2018, 9:08 p.m. UTC | #2
On Mon, Mar 26, 2018 at 04:10:18PM +0100, Colin Ian King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The current for-loop zeros variable i and only loops once, hence
> not all the buffers are free'd.  Fix this by setting i correctly.
> 
> Detected by CoverityScan, CID#1463415 ("Operands don't affect result")
> 
> Fixes: a5073d6054f7 ("RDMA/hns: Add eq support of hip08")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> Reviewed-by: Yixian Liu <liuyixian@huawei.com>
> ---
>  drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to for-rc, thanks

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 684c2d1a0ed0..8b84ab7800d8 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -4391,7 +4391,7 @@  static int hns_roce_mhop_alloc_eq(struct hns_roce_dev *hr_dev,
 	eq->l0_dma = 0;
 
 	if (mhop_num == 1)
-		for (i -= i; i >= 0; i--)
+		for (i -= 1; i >= 0; i--)
 			dma_free_coherent(dev, buf_chk_sz, eq->buf[i],
 					  eq->buf_dma[i]);
 	else if (mhop_num == 2) {