public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Gustavo A. R. Silva" <garsilva@embeddedor.com>,
	gregkh@linuxfoundation.org, balbi@kernel.org,
	bhelgaas@google.com, heikki.krogerus@linux.intel.com,
	mail@iagoabal.eu, mina86@mina86.com
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers: usb: gadget: udc: remove pointer dereference after free
Date: Wed, 08 Feb 2017 21:37:19 +0200	[thread overview]
Message-ID: <1486582639.2133.412.camel@linux.intel.com> (raw)
In-Reply-To: <20170208191549.GA3998@embeddedgus>

On Wed, 2017-02-08 at 13:15 -0600, Gustavo A. R. Silva wrote:
> Remove pointer dereference and write after free.

It's wrong description. There is no write after free. The memory is
still in pool and one may access it. Though the access is *formally*
illegal.

Code itself looks interesting.

> 
> Addresses-Coverity-ID: 1091173
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
>  drivers/usb/gadget/udc/pch_udc.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/udc/pch_udc.c
> b/drivers/usb/gadget/udc/pch_udc.c
> index a97da64..8a365aa 100644
> --- a/drivers/usb/gadget/udc/pch_udc.c
> +++ b/drivers/usb/gadget/udc/pch_udc.c
> @@ -1523,7 +1523,6 @@ static void pch_udc_free_dma_chain(struct
> pch_udc_dev *dev,
>  		td = phys_to_virt(addr);
>  		addr2 = (dma_addr_t)td->next;
>  		pci_pool_free(dev->data_requests, td, addr);
> -		td->next = 0x00;

I think the better fix is to move this line before pci_pool_free() call.
I dunno those td->next = 0x00; make any sense there.

Is it done under some lock / serialization?

>  		addr = addr2;
>  	}
>  	req->chain_len = 1;

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

  reply	other threads:[~2017-02-08 19:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-08 19:15 [PATCH] drivers: usb: gadget: udc: remove pointer dereference after free Gustavo A. R. Silva
2017-02-08 19:37 ` Andy Shevchenko [this message]
2017-02-08 21:33   ` Gustavo A. R. Silva
2017-02-11 17:07     ` [PATCH v2] " Gustavo A. R. Silva
2017-02-13 16:02       ` Michal Nazarewicz
2017-02-14  4:50         ` Gustavo A. R. Silva
2017-02-14  4:53           ` [PATCH v3] " Gustavo A. R. Silva
2017-03-10 11:35             ` Felipe Balbi
2017-03-10 21:20               ` Gustavo A. R. Silva
2017-03-10 21:39                 ` [PATCH v4] " 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=1486582639.2133.412.camel@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=balbi@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=garsilva@embeddedor.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mail@iagoabal.eu \
    --cc=mina86@mina86.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox