From: Michal Nazarewicz <mina86@mina86.com>
To: "Gustavo A. R. Silva" <garsilva@embeddedor.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: gregkh@linuxfoundation.org, balbi@kernel.org,
heikki.krogerus@linux.intel.com, mail@iagoabal.eu,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Peter Senna Tschudin <peter.senna@gmail.com>
Subject: Re: [PATCH v2] usb: gadget: udc: remove pointer dereference after free
Date: Mon, 13 Feb 2017 17:02:41 +0100 [thread overview]
Message-ID: <xa1tfujidqou.fsf@mina86.com> (raw)
In-Reply-To: <20170211110731.Horde.BPRpngvnMPXYcqid3jyhoJ-@gator4166.hostgator.com>
On Sat, Feb 11 2017, Gustavo A. R. Silva wrote:
> Remove pointer dereference after free and set pointer to NULL after free.
>
> Addresses-Coverity-ID: 1091173
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
> ---
> Changes in v2:
> Move pointer dereference before pci_pool_free()
> Set pointer to NULL after free
>
> drivers/usb/gadget/udc/pch_udc.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/udc/pch_udc.c
> b/drivers/usb/gadget/udc/pch_udc.c
> index a97da64..73bb58f 100644
> --- a/drivers/usb/gadget/udc/pch_udc.c
> +++ b/drivers/usb/gadget/udc/pch_udc.c
> @@ -1522,8 +1522,9 @@ static void pch_udc_free_dma_chain(struct
> pch_udc_dev *dev,
> /* do not free first desc., will be done by free for request */
> td = phys_to_virt(addr);
> addr2 = (dma_addr_t)td->next;
> - pci_pool_free(dev->data_requests, td, addr);
> td->next = 0x00;
Or just drop this. pci_pool_free doesn’t care about contents of td.
It’s just a void* for it.
> + pci_pool_free(dev->data_requests, td, addr);
> + td = NULL;
This isn’t necessary either. td will get overwritten on next iteration
and once we’re done it’s not used again.
> addr = addr2;
> }
> req->chain_len = 1;
--
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»
next prev parent reply other threads:[~2017-02-13 16:02 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
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 [this message]
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=xa1tfujidqou.fsf@mina86.com \
--to=mina86@mina86.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=balbi@kernel.org \
--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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox