提交 2891d4fe 编写于 作者: G Greg Kroah-Hartman

Revert "ARM: amba: Fix race condition with driver_override"

This reverts commit 6b614a87.

My backport was incorrect, as Geert pointed out :(
Reported-by: NGeert Uytterhoeven <geert@linux-m68k.org>
Cc: Todd Kjos <tkjos@google.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 d2ffed51
...@@ -69,15 +69,11 @@ static ssize_t driver_override_show(struct device *_dev, ...@@ -69,15 +69,11 @@ static ssize_t driver_override_show(struct device *_dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct amba_device *dev = to_amba_device(_dev); struct amba_device *dev = to_amba_device(_dev);
ssize_t len;
if (!dev->driver_override) if (!dev->driver_override)
return 0; return 0;
device_lock(_dev); return sprintf(buf, "%s\n", dev->driver_override);
len = sprintf(buf, "%s\n", dev->driver_override);
device_unlock(_dev);
return len;
} }
static ssize_t driver_override_store(struct device *_dev, static ssize_t driver_override_store(struct device *_dev,
...@@ -85,7 +81,7 @@ static ssize_t driver_override_store(struct device *_dev, ...@@ -85,7 +81,7 @@ static ssize_t driver_override_store(struct device *_dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct amba_device *dev = to_amba_device(_dev); struct amba_device *dev = to_amba_device(_dev);
char *driver_override, *old, *cp; char *driver_override, *old = dev->driver_override, *cp;
/* We need to keep extra room for a newline */ /* We need to keep extra room for a newline */
if (count >= (PAGE_SIZE - 1)) if (count >= (PAGE_SIZE - 1))
...@@ -99,15 +95,12 @@ static ssize_t driver_override_store(struct device *_dev, ...@@ -99,15 +95,12 @@ static ssize_t driver_override_store(struct device *_dev,
if (cp) if (cp)
*cp = '\0'; *cp = '\0';
device_lock(_dev);
old = dev->driver_override;
if (strlen(driver_override)) { if (strlen(driver_override)) {
dev->driver_override = driver_override; dev->driver_override = driver_override;
} else { } else {
kfree(driver_override); kfree(driver_override);
dev->driver_override = NULL; dev->driver_override = NULL;
} }
device_unlock(_dev);
kfree(old); kfree(old);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册