Re: [PATCH] bluetooth: don't DMA to stack in btsdio driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 27, 2009 at 4:28 PM, David Vrabel <david.vrabel@xxxxxxx> wrote:
> sdio_read() may use DMA so read the Type-A header into a kmalloc'd
> buffer instead of an on-stack buffer (which results in a DMA API
> warning).
>
> Signed-off-by: David Vrabel <david.vrabel@xxxxxxx>
> ---
> Apply this instead, it frees the header buffer.
>
> David
>
>  drivers/bluetooth/btsdio.c |   35 ++++++++++++++++++++++-------------
>  1 files changed, 22 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/bluetooth/btsdio.c b/drivers/bluetooth/btsdio.c
> index 7e29827..59d0d3b 100644
> --- a/drivers/bluetooth/btsdio.c
> +++ b/drivers/bluetooth/btsdio.c
> @@ -54,6 +54,7 @@ MODULE_DEVICE_TABLE(sdio, btsdio_table);
>  struct btsdio_data {
>        struct hci_dev   *hdev;
>        struct sdio_func *func;
> +       u8 *hdr_buf;
>
>        struct work_struct work;
>
> @@ -122,7 +123,7 @@ static void btsdio_work(struct work_struct *work)
>
>  static int btsdio_rx_packet(struct btsdio_data *data)
>  {
> -       u8 hdr[4] __attribute__ ((aligned(4)));
> +       u8 *hdr = data->hdr_buf;
>        struct sk_buff *skb;
>        int err, len;
>
> @@ -292,6 +293,7 @@ static void btsdio_destruct(struct hci_dev *hdev)
>
>        BT_DBG("%s", hdev->name);
>
> +       kfree(data->hdr_buf);
>        kfree(data);
>  }
>
> @@ -299,9 +301,9 @@ static int btsdio_probe(struct sdio_func *func,
>                                const struct sdio_device_id *id)
>  {
>        struct btsdio_data *data;
> -       struct hci_dev *hdev;
> +       struct hci_dev *hdev = NULL;

This kind of assignments prevent useful warning from compiler, maybe
it's better to stage
the error bailout.

>        struct sdio_func_tuple *tuple = func->tuples;
> -       int err;
> +       int err = -ENOMEM;
You are assuming no other code  between 2 allocations, it's seems to
me error prone.
>

Thanks
Tomas
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux