Skip to contentSkip to conversation

media: rc: xbox_remote: heed DMA restrictions

PATCH New Oliver Neukum 1 participant 1 message Feb 11

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 2/4 media: rc: xbox_remote: heed DMA restrictions

The buffer for IO must not be part f the device structure because that violates the DMA coherency rules.

Fixes 02d32bdad3123 ("media: rc: add driver for Xbox DVD Movie Playback Kit")
---
 drivers/media/rc/xbox_remote.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/media/rc/xbox_remote.c +5 -2
index a1572381d097..71087594e86a 100644
@@ -55,7 +55,7 @@ struct xbox_remote {
 	struct usb_interface *interface;
 
 	struct urb *irq_urb;
-	unsigned char inbuf[DATA_BUFSIZE] __aligned(sizeof(u16));
+	u8 *inbuf;
 
 	char rc_name[NAME_BUFSIZE];
 	char rc_phys[NAME_BUFSIZE];
@@ -215,7 +215,8 @@ static int xbox_remote_probe(struct usb_interface *interface,
 
 	xbox_remote = kzalloc(sizeof(*xbox_remote), GFP_KERNEL);
 	rc_dev = rc_allocate_device(RC_DRIVER_SCANCODE);
-	if (!xbox_remote || !rc_dev)
+	xbox_remote->inbuf = kzalloc(DATA_BUFSIZE, GFP_KERNEL);
+	if (!xbox_remote || !rc_dev || !xbox_remote->inbuf)
 		goto exit_free_dev_rdev;
 
 	/* Allocate URB buffer */
@@ -264,6 +265,7 @@ static int xbox_remote_probe(struct usb_interface *interface,
 	usb_free_urb(xbox_remote->irq_urb);
 exit_free_dev_rdev:
 	rc_free_device(rc_dev);
+	kfree(xbox_remote->inbuf);
 	kfree(xbox_remote);
 
 	return err;
@@ -286,6 +288,7 @@ static void xbox_remote_disconnect(struct usb_interface *interface)
 	usb_kill_urb(xbox_remote->irq_urb);
 	rc_unregister_device(xbox_remote->rdev);
 	usb_free_urb(xbox_remote->irq_urb);
+	kfree(xbox_remote->inbuf);
 	kfree(xbox_remote);
 }
 
Signature · 1 line
2.53.0