Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1503290 > unrolled thread

[PATCH] qedr: return -EINVAL if pd is null and avoid null ptr dereference

Started byColin King <colin.king@canonical.com>
First post2016-10-18 20:50 +0200
Last post2016-10-20 11:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] qedr: return -EINVAL if pd is null and avoid null ptr dereference Colin King <colin.king@canonical.com> - 2016-10-18 20:50 +0200
    RE: [PATCH] qedr: return -EINVAL if pd is null and avoid null ptr  dereference "Amrani, Ram" <Ram.Amrani@cavium.com> - 2016-10-20 11:50 +0200

#1503290 — [PATCH] qedr: return -EINVAL if pd is null and avoid null ptr dereference

FromColin King <colin.king@canonical.com>
Date2016-10-18 20:50 +0200
Subject[PATCH] qedr: return -EINVAL if pd is null and avoid null ptr dereference
Message-ID<stHCy-5H5-9@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

Currently, if pd is null then we hit a null pointer derference
on accessing pd->pd_id.  Instead of just printing an error message
we should also return -EINVAL immediately.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/infiniband/hw/qedr/verbs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
index a615142..b2a0eb8 100644
--- a/drivers/infiniband/hw/qedr/verbs.c
+++ b/drivers/infiniband/hw/qedr/verbs.c
@@ -511,8 +511,10 @@ int qedr_dealloc_pd(struct ib_pd *ibpd)
 	struct qedr_dev *dev = get_qedr_dev(ibpd->device);
 	struct qedr_pd *pd = get_qedr_pd(ibpd);
 
-	if (!pd)
+	if (!pd) {
 		pr_err("Invalid PD received in dealloc_pd\n");
+		return -EINVAL;
+	}
 
 	DP_DEBUG(dev, QEDR_MSG_INIT, "Deallocating PD %d\n", pd->pd_id);
 	dev->ops->rdma_dealloc_pd(dev->rdma_ctx, pd->pd_id);
-- 
2.9.3

[toc] | [next] | [standalone]


#1504715 — RE: [PATCH] qedr: return -EINVAL if pd is null and avoid null ptr dereference

From"Amrani, Ram" <Ram.Amrani@cavium.com>
Date2016-10-20 11:50 +0200
SubjectRE: [PATCH] qedr: return -EINVAL if pd is null and avoid null ptr dereference
Message-ID<sui93-5JM-5@gated-at.bofh.it>
In reply to#1503290
>  drivers/infiniband/hw/qedr/verbs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/qedr/verbs.c
> b/drivers/infiniband/hw/qedr/verbs.c
> index a615142..b2a0eb8 100644
> --- a/drivers/infiniband/hw/qedr/verbs.c
> +++ b/drivers/infiniband/hw/qedr/verbs.c
> @@ -511,8 +511,10 @@ int qedr_dealloc_pd(struct ib_pd *ibpd)
>  	struct qedr_dev *dev = get_qedr_dev(ibpd->device);
>  	struct qedr_pd *pd = get_qedr_pd(ibpd);
> 
> -	if (!pd)
> +	if (!pd) {
>  		pr_err("Invalid PD received in dealloc_pd\n");
> +		return -EINVAL;
> +	}
> 
>  	DP_DEBUG(dev, QEDR_MSG_INIT, "Deallocating PD %d\n", pd->pd_id);
>  	dev->ops->rdma_dealloc_pd(dev->rdma_ctx, pd->pd_id);
> --
> 2.9.3

Thanks Colin.

Acked-by: Ram Amrani <ram.amrani@cavium.com>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web