linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.de>
To: Joe Perches <joe@perches.com>
Cc: "David Barksdale" <dbarksdale@uplogix.com>,
	"David Herrmann" <dh.herrmann@gmail.com>,
	"Jiri Kosina" <jkosina@suse.cz>,
	"Benjamin Tissoires" <benjamin.tissoires@redhat.com>,
	"Jakub Kákona" <kjakub@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] HID: New hid-cp2112 driver
Date: Thu, 30 Jan 2014 08:35:07 +0100	[thread overview]
Message-ID: <1391067307.11310.3.camel@linux-fkkt.site> (raw)
In-Reply-To: <1391039165.2422.11.camel@joe-AO722>

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.

	Regards
		Oliver



  reply	other threads:[~2014-01-30  9:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-29 23:26 [PATCH v4] HID: New hid-cp2112 driver David Barksdale
2014-01-29 23:46 ` Joe Perches
2014-01-30  7:35   ` Oliver Neukum [this message]
2014-01-30  9:52     ` Joe Perches
2014-01-30 12:49       ` Oliver Neukum
2014-01-31 10:41 ` Jiri Kosina

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=1391067307.11310.3.camel@linux-fkkt.site \
    --to=oneukum@suse.de \
    --cc=benjamin.tissoires@redhat.com \
    --cc=dbarksdale@uplogix.com \
    --cc=dh.herrmann@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=joe@perches.com \
    --cc=kjakub@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).