From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: linux1394-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: swiotlb default size (64 MB) too small?
Date: Wed, 28 Jan 2009 01:03:34 +0100 (CET) [thread overview]
Message-ID: <tkrat.511cc93cd769cafe@s5r6.in-berlin.de> (raw)
In-Reply-To: <497F9CC5.8080807@s5r6.in-berlin.de>
> FUJITA Tomonori wrote:
>> On Tue, 27 Jan 2009 18:03:40 +0100 (CET)
>> Stefan Richter <stefanr@s5r6.in-berlin.de> wrote:
>>> + if (orb->page_table_bus)
>>> + dma_unmap_single(card_device, orb->page_table_bus,
>>> + sizeof(orb->page_table), DMA_TO_DEVICE);
>>
>> Well, this does not look correct since zero can be a valid dma
>> address.
From: Stefan Richter <stefanr@s5r6.in-berlin.de>
Subject: firewire: sbp2: fix DMA mapping leak on the failure path
Reported-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
who also provided a first version of the fix.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
drivers/firewire/fw-sbp2.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
Index: linux/drivers/firewire/fw-sbp2.c
===================================================================
--- linux.orig/drivers/firewire/fw-sbp2.c
+++ linux/drivers/firewire/fw-sbp2.c
@@ -1323,6 +1323,19 @@ static unsigned int sbp2_status_to_sense
}
}
+static void sbp2_unmap_scatterlist(struct device *card_device,
+ struct sbp2_command_orb *orb)
+{
+ if (scsi_sg_count(orb->cmd))
+ dma_unmap_sg(card_device, scsi_sglist(orb->cmd),
+ scsi_sg_count(orb->cmd),
+ orb->cmd->sc_data_direction);
+
+ if (orb->request.misc & cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT))
+ dma_unmap_single(card_device, orb->page_table_bus,
+ sizeof(orb->page_table), DMA_TO_DEVICE);
+}
+
static void complete_command_orb(struct sbp2_orb *base_orb,
struct sbp2_status *status)
{
@@ -1364,15 +1377,7 @@ static void complete_command_orb(struct
dma_unmap_single(device->card->device, orb->base.request_bus,
sizeof(orb->request), DMA_TO_DEVICE);
-
- if (scsi_sg_count(orb->cmd) > 0)
- dma_unmap_sg(device->card->device, scsi_sglist(orb->cmd),
- scsi_sg_count(orb->cmd),
- orb->cmd->sc_data_direction);
-
- if (orb->page_table_bus != 0)
- dma_unmap_single(device->card->device, orb->page_table_bus,
- sizeof(orb->page_table), DMA_TO_DEVICE);
+ sbp2_unmap_scatterlist(device->card->device, orb);
orb->cmd->result = result;
orb->done(orb->cmd);
@@ -1493,8 +1498,10 @@ static int sbp2_scsi_queuecommand(struct
orb->base.request_bus =
dma_map_single(device->card->device, &orb->request,
sizeof(orb->request), DMA_TO_DEVICE);
- if (dma_mapping_error(device->card->device, orb->base.request_bus))
+ if (dma_mapping_error(device->card->device, orb->base.request_bus)) {
+ sbp2_unmap_scatterlist(device->card->device, orb);
goto out;
+ }
sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation,
lu->command_block_agent_address + SBP2_ORB_POINTER);
--
Stefan Richter
-=====-==--= ---= ===--
http://arcgraph.de/sr/
next prev parent reply other threads:[~2009-01-28 0:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-20 20:10 swiotlb default size (64 MB) too small? Stefan Richter
2009-01-20 22:44 ` FUJITA Tomonori
2009-01-21 7:56 ` Stefan Richter
2009-01-27 7:54 ` FUJITA Tomonori
2009-01-27 9:36 ` FUJITA Tomonori
2009-01-27 17:03 ` Stefan Richter
2009-01-27 23:31 ` FUJITA Tomonori
2009-01-27 23:46 ` Stefan Richter
2009-01-27 23:57 ` FUJITA Tomonori
2009-01-28 0:03 ` Stefan Richter [this message]
2009-01-28 0:35 ` FUJITA Tomonori
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=tkrat.511cc93cd769cafe@s5r6.in-berlin.de \
--to=stefanr@s5r6.in-berlin.de \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux1394-devel@lists.sourceforge.net \
/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