Commit 7dae5bff authored by Bryan O'Sullivan's avatar Bryan O'Sullivan Committed by Roland Dreier

IB/ipath: Only allow complete writes to flash

Don't allow a write to the eeprom from ipathfs unless the write is exactly
128 bytes and starts at offset 0.
Signed-off-by: default avatarBryan O'Sullivan <bryan.osullivan@qlogic.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent f3e93c77
...@@ -356,19 +356,16 @@ static ssize_t flash_write(struct file *file, const char __user *buf, ...@@ -356,19 +356,16 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
pos = *ppos; pos = *ppos;
if ( pos < 0) { if (pos != 0) {
ret = -EINVAL; ret = -EINVAL;
goto bail; goto bail;
} }
if (pos >= sizeof(struct ipath_flash)) { if (count != sizeof(struct ipath_flash)) {
ret = 0; ret = -EINVAL;
goto bail; goto bail;
} }
if (count > sizeof(struct ipath_flash) - pos)
count = sizeof(struct ipath_flash) - pos;
tmp = kmalloc(count, GFP_KERNEL); tmp = kmalloc(count, GFP_KERNEL);
if (!tmp) { if (!tmp) {
ret = -ENOMEM; ret = -ENOMEM;
......
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