Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1364871

Re: [PATCH] USB: whci-hcd: add more checks for dma mapping error

Path csiph.com!news.freedyn.net!aioe.org!bofh.it!news.nic.it!robomod
From Alexey Khoroshilov <khoroshilov@ispras.ru>
Newsgroups linux.kernel
Subject Re: [PATCH] USB: whci-hcd: add more checks for dma mapping error
Date Sat, 26 Mar 2016 00:00:02 +0100
Message-ID <rgIRY-a2-9@gated-at.bofh.it> (permalink)
References <rgGwO-7aX-3@gated-at.bofh.it> <rgI5A-8hV-15@gated-at.bofh.it>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0
MIME-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 42
Organization linux.* mail to news gateway
X-Original-Cc linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org
X-Original-Date Sat, 26 Mar 2016 01:56:52 +0300
X-Original-Message-ID <56F5C234.3070606@ispras.ru>
X-Original-References <1458937421-18120-1-git-send-email-khoroshilov@ispras.ru> <56F5B59C.3050001@mleia.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1364871

Show key headers only | View raw


On 26.03.2016 01:03, Vladimir Zapolskiy wrote:
> On 25.03.2016 22:23, Alexey Khoroshilov wrote:
>> Fixing checks for dma mapping error in qset_fill_page_list(),
>> I have missed two similar problems in qset_add_urb_sg() and
>> in qset_add_urb_sg_linearize().
>>
>> Found by Linux Driver Verification project (linuxtesting.org).
>>
>> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
>> ---
>>   drivers/usb/host/whci/qset.c | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/host/whci/qset.c b/drivers/usb/host/whci/qset.c
>> index 1a8e960d073b..a8e9b618e643 100644
>> --- a/drivers/usb/host/whci/qset.c
>> +++ b/drivers/usb/host/whci/qset.c
>> @@ -535,9 +535,11 @@ static int qset_add_urb_sg(struct whc *whc, struct whc_qset *qset, struct urb *u
>>   	list_for_each_entry(std, &qset->stds, list_node) {
>>   		if (std->ntds_remaining == -1) {
>>   			pl_len = std->num_pointers * sizeof(struct whc_page_list_entry);
>> -			std->ntds_remaining = ntds--;
>>   			std->dma_addr = dma_map_single(whc->wusbhc.dev, std->pl_virt,
>>   						       pl_len, DMA_TO_DEVICE);
>> +			if (dma_mapping_error(whc->wusbhc.dev, std->dma_addr))
>> +				return -EFAULT;
>
> Resources are leaked on error path:
> * std->pl_virt  -- most probably, at least it is freed on error path above,
> * dma mappings done in a loop before met error,
>

As far as I can see, it is not the case.
If qset_add_urb_sg() returns error code, the caller (qset_add_urb()) 
invokes qset_free_stds() that performs all resource deallocations.

As for the error path above, I consider it as a typical krealloc() 
pattern, since it does not frees memory allocated at previous iterations 
of the cycle.

Thank you,
Alexey

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] USB: whci-hcd: add more checks for dma mapping error Alexey Khoroshilov <khoroshilov@ispras.ru> - 2016-03-25 21:30 +0100
  Re: [PATCH] USB: whci-hcd: add more checks for dma mapping error Vladimir Zapolskiy <vz@mleia.com> - 2016-03-25 23:10 +0100
    Re: [PATCH] USB: whci-hcd: add more checks for dma mapping error Alexey Khoroshilov <khoroshilov@ispras.ru> - 2016-03-26 00:00 +0100
      Re: [PATCH] USB: whci-hcd: add more checks for dma mapping error Vladimir Zapolskiy <vz@mleia.com> - 2016-03-26 01:30 +0100
        [PATCH v2] USB: whci-hcd: add more checks for dma mapping error Alexey Khoroshilov <khoroshilov@ispras.ru> - 2016-03-26 20:50 +0100
          Re: [PATCH v2] USB: whci-hcd: add more checks for dma mapping error Vladimir Zapolskiy <vz@mleia.com> - 2016-03-30 09:50 +0200

csiph-web