diff options
Diffstat (limited to 'arch/powerpc/kernel/rtas_flash.c')
| -rw-r--r-- | arch/powerpc/kernel/rtas_flash.c | 53 |
1 files changed, 6 insertions, 47 deletions
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c index 2b442e6c21e6..bf5f5ce3a7bd 100644 --- a/arch/powerpc/kernel/rtas_flash.c +++ b/arch/powerpc/kernel/rtas_flash.c | |||
| @@ -256,31 +256,16 @@ static ssize_t rtas_flash_read(struct file *file, char __user *buf, | |||
| 256 | struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode); | 256 | struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode); |
| 257 | struct rtas_update_flash_t *uf; | 257 | struct rtas_update_flash_t *uf; |
| 258 | char msg[RTAS_MSG_MAXLEN]; | 258 | char msg[RTAS_MSG_MAXLEN]; |
| 259 | int msglen; | ||
| 260 | 259 | ||
| 261 | uf = (struct rtas_update_flash_t *) dp->data; | 260 | uf = dp->data; |
| 262 | 261 | ||
| 263 | if (!strcmp(dp->name, FIRMWARE_FLASH_NAME)) { | 262 | if (!strcmp(dp->name, FIRMWARE_FLASH_NAME)) { |
| 264 | get_flash_status_msg(uf->status, msg); | 263 | get_flash_status_msg(uf->status, msg); |
| 265 | } else { /* FIRMWARE_UPDATE_NAME */ | 264 | } else { /* FIRMWARE_UPDATE_NAME */ |
| 266 | sprintf(msg, "%d\n", uf->status); | 265 | sprintf(msg, "%d\n", uf->status); |
| 267 | } | 266 | } |
| 268 | msglen = strlen(msg); | ||
| 269 | if (msglen > count) | ||
| 270 | msglen = count; | ||
| 271 | |||
| 272 | if (ppos && *ppos != 0) | ||
| 273 | return 0; /* be cheap */ | ||
| 274 | |||
| 275 | if (!access_ok(VERIFY_WRITE, buf, msglen)) | ||
| 276 | return -EINVAL; | ||
| 277 | 267 | ||
| 278 | if (copy_to_user(buf, msg, msglen)) | 268 | return simple_read_from_buffer(buf, count, ppos, msg, strlen(msg)); |
| 279 | return -EFAULT; | ||
| 280 | |||
| 281 | if (ppos) | ||
| 282 | *ppos = msglen; | ||
| 283 | return msglen; | ||
| 284 | } | 269 | } |
| 285 | 270 | ||
| 286 | /* constructor for flash_block_cache */ | 271 | /* constructor for flash_block_cache */ |
| @@ -394,26 +379,13 @@ static ssize_t manage_flash_read(struct file *file, char __user *buf, | |||
| 394 | char msg[RTAS_MSG_MAXLEN]; | 379 | char msg[RTAS_MSG_MAXLEN]; |
| 395 | int msglen; | 380 | int msglen; |
| 396 | 381 | ||
| 397 | args_buf = (struct rtas_manage_flash_t *) dp->data; | 382 | args_buf = dp->data; |
| 398 | if (args_buf == NULL) | 383 | if (args_buf == NULL) |
| 399 | return 0; | 384 | return 0; |
| 400 | 385 | ||
| 401 | msglen = sprintf(msg, "%d\n", args_buf->status); | 386 | msglen = sprintf(msg, "%d\n", args_buf->status); |
| 402 | if (msglen > count) | ||
| 403 | msglen = count; | ||
| 404 | 387 | ||
| 405 | if (ppos && *ppos != 0) | 388 | return simple_read_from_buffer(buf, count, ppos, msg, msglen); |
| 406 | return 0; /* be cheap */ | ||
| 407 | |||
| 408 | if (!access_ok(VERIFY_WRITE, buf, msglen)) | ||
| 409 | return -EINVAL; | ||
| 410 | |||
| 411 | if (copy_to_user(buf, msg, msglen)) | ||
| 412 | return -EFAULT; | ||
| 413 | |||
| 414 | if (ppos) | ||
| 415 | *ppos = msglen; | ||
| 416 | return msglen; | ||
| 417 | } | 389 | } |
| 418 | 390 | ||
| 419 | static ssize_t manage_flash_write(struct file *file, const char __user *buf, | 391 | static ssize_t manage_flash_write(struct file *file, const char __user *buf, |
| @@ -495,24 +467,11 @@ static ssize_t validate_flash_read(struct file *file, char __user *buf, | |||
| 495 | char msg[RTAS_MSG_MAXLEN]; | 467 | char msg[RTAS_MSG_MAXLEN]; |
| 496 | int msglen; | 468 | int msglen; |
| 497 | 469 | ||
| 498 | args_buf = (struct rtas_validate_flash_t *) dp->data; | 470 | args_buf = dp->data; |
| 499 | 471 | ||
| 500 | if (ppos && *ppos != 0) | ||
| 501 | return 0; /* be cheap */ | ||
| 502 | |||
| 503 | msglen = get_validate_flash_msg(args_buf, msg); | 472 | msglen = get_validate_flash_msg(args_buf, msg); |
| 504 | if (msglen > count) | ||
| 505 | msglen = count; | ||
| 506 | |||
| 507 | if (!access_ok(VERIFY_WRITE, buf, msglen)) | ||
| 508 | return -EINVAL; | ||
| 509 | |||
| 510 | if (copy_to_user(buf, msg, msglen)) | ||
| 511 | return -EFAULT; | ||
| 512 | 473 | ||
| 513 | if (ppos) | 474 | return simple_read_from_buffer(buf, count, ppos, msg, msglen); |
| 514 | *ppos = msglen; | ||
| 515 | return msglen; | ||
| 516 | } | 475 | } |
| 517 | 476 | ||
| 518 | static ssize_t validate_flash_write(struct file *file, const char __user *buf, | 477 | static ssize_t validate_flash_write(struct file *file, const char __user *buf, |
