[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1391075579.2422.53.camel@joe-AO722>
Date: Thu, 30 Jan 2014 01:52:59 -0800
From: Joe Perches <joe@...ches.com>
To: Oliver Neukum <oneukum@...e.de>
Cc: David Barksdale <dbarksdale@...ogix.com>,
David Herrmann <dh.herrmann@...il.com>,
Jiri Kosina <jkosina@...e.cz>,
Benjamin Tissoires <benjamin.tissoires@...hat.com>,
Jakub Kákona <kjakub@...il.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4] HID: New hid-cp2112 driver
On Thu, 2014-01-30 at 08:35 +0100, Oliver Neukum wrote:
> On Wed, 2014-01-29 at 15:46 -0800, Joe Perches wrote:
>
> > > +static int cp2112_hid_get(struct hid_device *hdev, unsigned char report_number,
> > > + u8 *data, size_t count, unsigned char report_type)
> > > +{
> > > + u8 *buf;
> > > + int ret;
> > > +
> > > + buf = kmalloc(count, GFP_KERNEL);
> > > + if (!buf)
> > > + return -ENOMEM;
> > > +
> > > + ret = hdev->hid_get_raw_report(hdev, report_number, buf, count,
> > > + report_type);
> > > + memcpy(data, buf, count);
> > > + kfree(buf);
> > > + return ret;
> >
> > if the data is going to be copied in data,
> > why not just use data in hid_get_raw_report
> > and avoid the malloc?
>
> He must not. It would violate the DMA rules. This function is passed
> pointers to parts of structures. Access to the structures may race
> with a DMA to/from the buffer. That violates the DMA rules.
If this is going to be used to DMA, doesn't
the alloc need to be GFP_KERNEL | GFP_DMA ?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists