diff options
Diffstat (limited to 'drivers/base/firmware_class.c')
-rw-r--r-- | drivers/base/firmware_class.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index e97e911ebf7a..472318205236 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -211,18 +211,20 @@ static int | |||
211 | fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) | 211 | fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) |
212 | { | 212 | { |
213 | u8 *new_data; | 213 | u8 *new_data; |
214 | int new_size = fw_priv->alloc_size; | ||
214 | 215 | ||
215 | if (min_size <= fw_priv->alloc_size) | 216 | if (min_size <= fw_priv->alloc_size) |
216 | return 0; | 217 | return 0; |
217 | 218 | ||
218 | new_data = vmalloc(fw_priv->alloc_size + PAGE_SIZE); | 219 | new_size = ALIGN(min_size, PAGE_SIZE); |
220 | new_data = vmalloc(new_size); | ||
219 | if (!new_data) { | 221 | if (!new_data) { |
220 | printk(KERN_ERR "%s: unable to alloc buffer\n", __FUNCTION__); | 222 | printk(KERN_ERR "%s: unable to alloc buffer\n", __FUNCTION__); |
221 | /* Make sure that we don't keep incomplete data */ | 223 | /* Make sure that we don't keep incomplete data */ |
222 | fw_load_abort(fw_priv); | 224 | fw_load_abort(fw_priv); |
223 | return -ENOMEM; | 225 | return -ENOMEM; |
224 | } | 226 | } |
225 | fw_priv->alloc_size += PAGE_SIZE; | 227 | fw_priv->alloc_size = new_size; |
226 | if (fw_priv->fw->data) { | 228 | if (fw_priv->fw->data) { |
227 | memcpy(new_data, fw_priv->fw->data, fw_priv->fw->size); | 229 | memcpy(new_data, fw_priv->fw->data, fw_priv->fw->size); |
228 | vfree(fw_priv->fw->data); | 230 | vfree(fw_priv->fw->data); |