All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@kernel.org>
To: "Gustavo A. R. Silva" <garsilva@embeddedor.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Michal Nazarewicz <mina86@mina86.com>
Cc: linux-geode@lists.infradead.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Peter Senna Tschudin <peter.senna@gmail.com>
Subject: Re: [usb-gadget-udc] question about null check after calling phys_to_virt() function
Date: Tue, 16 May 2017 11:10:51 +0300	[thread overview]
Message-ID: <87r2zpw7as.fsf@linux.intel.com> (raw)
In-Reply-To: <20170502152440.Horde.MRwIGqwH6RD-MhJ68l8bMDc@gator4166.hostgator.com>

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


Hi,

"Gustavo A. R. Silva" <garsilva@embeddedor.com> writes:
> Hello everybody,
>
> While looking into Coverity ID 145958 I ran into the following piece  
> of code at drivers/usb/gadget/udc/amd5536udc.c:852:
>
> } else if (i == buf_len) {
>          /* first td */
>          td = (struct udc_data_dma *)phys_to_virt(
>                                  req->td_data->next);
>          td->status = 0;
> } else {
>          td = (struct udc_data_dma *)phys_to_virt(last->next);
>          td->status = 0;
> }
>
> if (td)
>          td->bufptr = req->req.dma + i; /* assign buffer */
> else
>          break;
>
> The issue here is that _td_ pointer is being dereferenced before null check.
>
> After searching for calls to phys_to_virt() function, I've noticed  
> that is not common at all to test the returned address value.
>
> So either the null check at line 862 is not needed or a null check  
> before each td->status = 0; needs to be added.

just remove the previous null check

-- 
balbi

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

  reply	other threads:[~2017-05-16  8:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-02 20:24 [usb-gadget-udc] question about null check after calling phys_to_virt() function Gustavo A. R. Silva
2017-05-16  8:10 ` Felipe Balbi [this message]
2017-05-16 16:28   ` Gustavo A. R. Silva

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=87r2zpw7as.fsf@linux.intel.com \
    --to=balbi@kernel.org \
    --cc=garsilva@embeddedor.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-geode@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mina86@mina86.com \
    --cc=peter.senna@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.