linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: "Gustavo A. R. Silva"
	<garsilva-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org>,
	Ram Amrani <ram.amrani-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Hal Rosenstock
	<hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] infiniband: hw: qedr: add null check before pointer dereference
Date: Tue, 23 May 2017 10:13:49 +0300	[thread overview]
Message-ID: <20170523071349.GF17751@mtr-leonro.local> (raw)
In-Reply-To: <20170522183015.GA22310@embeddedgus>

[-- Attachment #1: Type: text/plain, Size: 1402 bytes --]

On Mon, May 22, 2017 at 01:30:15PM -0500, Gustavo A. R. Silva wrote:
> Add null check before dereferencing pointer sgid_attr.ndev
> inside function rdma_vlan_dev_vlan_id().
>
> Addresses-Coverity-ID: 1373979
> Signed-off-by: Gustavo A. R. Silva <garsilva-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org>
> ---
>  drivers/infiniband/hw/qedr/qedr_cm.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)

+ Ram,

Ram, IB part of qedr driver doesn't exist in MAINTAINERS file.

>
> diff --git a/drivers/infiniband/hw/qedr/qedr_cm.c b/drivers/infiniband/hw/qedr/qedr_cm.c
> index 3d7705c..d86dbe8 100644
> --- a/drivers/infiniband/hw/qedr/qedr_cm.c
> +++ b/drivers/infiniband/hw/qedr/qedr_cm.c
> @@ -270,11 +270,13 @@ static inline int qedr_gsi_build_header(struct qedr_dev *dev,
>  		return rc;
>  	}
>
> -	vlan_id = rdma_vlan_dev_vlan_id(sgid_attr.ndev);
> -	if (vlan_id < VLAN_CFI_MASK)
> -		has_vlan = true;
> -	if (sgid_attr.ndev)
> +	if (sgid_attr.ndev) {
> +		vlan_id = rdma_vlan_dev_vlan_id(sgid_attr.ndev);
> +		if (vlan_id < VLAN_CFI_MASK)
> +			has_vlan = true;
> +
>  		dev_put(sgid_attr.ndev);
> +	}

I do agree that it is better than kernel panic trying to access NULL
pointer, but I'm not sure that retaining default vlan_id = 0 is correct
solution here.

>
>  	if (!memcmp(&sgid, &zgid, sizeof(sgid))) {
>  		DP_ERR(dev, "gsi post send: GID not found GID index %d\n",
> --
> 2.5.0
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-05-23  7:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-22 18:30 [PATCH] infiniband: hw: qedr: add null check before pointer dereference Gustavo A. R. Silva
2017-05-23  7:13 ` Leon Romanovsky [this message]
     [not found]   ` <20170523071349.GF17751-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-05-23 15:03     ` Amrani, Ram
2017-05-23 15:09 ` Amrani, Ram
2017-06-01 22:32 ` Doug Ledford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170523071349.GF17751@mtr-leonro.local \
    --to=leon-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=garsilva-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org \
    --cc=hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ram.amrani-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org \
    --cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).