mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] qedr: return -EINVAL if pd is null and avoid null ptr dereference
@ 2016-10-18 18:39 Colin King
  2016-10-20  7:12 ` Amrani, Ram
  2016-12-14 16:25 ` Doug Ledford
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2016-10-18 18:39 UTC (permalink / raw)
  To: Doug Ledford, Sean Hefty, Hal Rosenstock, Rajesh Borundia,
	Ram Amrani, linux-rdma
  Cc: linux-kernel

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

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

* RE: [PATCH] qedr: return -EINVAL if pd is null and avoid null ptr dereference
  2016-10-18 18:39 [PATCH] qedr: return -EINVAL if pd is null and avoid null ptr dereference Colin King
@ 2016-10-20  7:12 ` Amrani, Ram
  2016-12-14 16:25 ` Doug Ledford
  1 sibling, 0 replies; 3+ messages in thread
From: Amrani, Ram @ 2016-10-20  7:12 UTC (permalink / raw)
  To: Colin King, Doug Ledford, Sean Hefty, Hal Rosenstock, Borundia,
	Rajesh, linux-rdma
  Cc: linux-kernel

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

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

* Re: [PATCH] qedr: return -EINVAL if pd is null and avoid null ptr dereference
  2016-10-18 18:39 [PATCH] qedr: return -EINVAL if pd is null and avoid null ptr dereference Colin King
  2016-10-20  7:12 ` Amrani, Ram
@ 2016-12-14 16:25 ` Doug Ledford
  1 sibling, 0 replies; 3+ messages in thread
From: Doug Ledford @ 2016-12-14 16:25 UTC (permalink / raw)
  To: Colin King, Sean Hefty, Hal Rosenstock, Rajesh Borundia,
	Ram Amrani, linux-rdma
  Cc: linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 434 bytes --]

On 10/18/2016 2:39 PM, Colin King wrote:
> 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>

Applied, thanks.

-- 
Doug Ledford <dledford@redhat.com>
    GPG Key ID: 0E572FDD


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

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

end of thread, other threads:[~2016-12-14 16:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-18 18:39 [PATCH] qedr: return -EINVAL if pd is null and avoid null ptr dereference Colin King
2016-10-20  7:12 ` Amrani, Ram
2016-12-14 16:25 ` Doug Ledford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®