Commit d314e9e8 authored by Oliver Neukum's avatar Oliver Neukum Committed by Dmitry Torokhov

Input: sur40 - fix DMA on stack

During the initialisation the driver uses a buffer on the stack for DMA.
That violates the cache coherency rules. The fix is to allocate the buffer
with kmalloc().
Signed-off-by: default avatarOliver Neukum <ONeukum@suse.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 950336ba
...@@ -197,28 +197,34 @@ static int sur40_command(struct sur40_state *dev, ...@@ -197,28 +197,34 @@ static int sur40_command(struct sur40_state *dev,
static int sur40_init(struct sur40_state *dev) static int sur40_init(struct sur40_state *dev)
{ {
int result; int result;
u8 buffer[24]; u8 *buffer;
buffer = kmalloc(24, GFP_KERNEL);
if (!buffer) {
result = -ENOMEM;
goto error;
}
/* stupidly replay the original MS driver init sequence */ /* stupidly replay the original MS driver init sequence */
result = sur40_command(dev, SUR40_GET_VERSION, 0x00, buffer, 12); result = sur40_command(dev, SUR40_GET_VERSION, 0x00, buffer, 12);
if (result < 0) if (result < 0)
return result; goto error;
result = sur40_command(dev, SUR40_GET_VERSION, 0x01, buffer, 12); result = sur40_command(dev, SUR40_GET_VERSION, 0x01, buffer, 12);
if (result < 0) if (result < 0)
return result; goto error;
result = sur40_command(dev, SUR40_GET_VERSION, 0x02, buffer, 12); result = sur40_command(dev, SUR40_GET_VERSION, 0x02, buffer, 12);
if (result < 0) if (result < 0)
return result; goto error;
result = sur40_command(dev, SUR40_UNKNOWN2, 0x00, buffer, 24); result = sur40_command(dev, SUR40_UNKNOWN2, 0x00, buffer, 24);
if (result < 0) if (result < 0)
return result; goto error;
result = sur40_command(dev, SUR40_UNKNOWN1, 0x00, buffer, 5); result = sur40_command(dev, SUR40_UNKNOWN1, 0x00, buffer, 5);
if (result < 0) if (result < 0)
return result; goto error;
result = sur40_command(dev, SUR40_GET_VERSION, 0x03, buffer, 12); result = sur40_command(dev, SUR40_GET_VERSION, 0x03, buffer, 12);
...@@ -226,7 +232,8 @@ static int sur40_init(struct sur40_state *dev) ...@@ -226,7 +232,8 @@ static int sur40_init(struct sur40_state *dev)
* Discard the result buffer - no known data inside except * Discard the result buffer - no known data inside except
* some version strings, maybe extract these sometime... * some version strings, maybe extract these sometime...
*/ */
error:
kfree(buffer);
return result; return result;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment