@@ -312,13 +312,13 @@ static ssize_t rtas_flash_write(struct file *file, const char __user *buffer,
312
312
{
313
313
struct rtas_update_flash_t * const uf = & rtas_update_flash_data ;
314
314
char * p ;
315
- int next_free , rc ;
315
+ int next_free ;
316
316
struct flash_block_list * fl ;
317
317
318
- mutex_lock (& rtas_update_flash_mutex );
318
+ guard ( mutex ) (& rtas_update_flash_mutex );
319
319
320
320
if (uf -> status == FLASH_AUTH || count == 0 )
321
- goto out ; /* discard data */
321
+ return count ; /* discard data */
322
322
323
323
/* In the case that the image is not ready for flashing, the memory
324
324
* allocated for the block list will be freed upon the release of the
@@ -327,7 +327,7 @@ static ssize_t rtas_flash_write(struct file *file, const char __user *buffer,
327
327
if (uf -> flist == NULL ) {
328
328
uf -> flist = kmem_cache_zalloc (flash_block_cache , GFP_KERNEL );
329
329
if (!uf -> flist )
330
- goto nomem ;
330
+ return - ENOMEM ;
331
331
}
332
332
333
333
fl = uf -> flist ;
@@ -338,7 +338,7 @@ static ssize_t rtas_flash_write(struct file *file, const char __user *buffer,
338
338
/* Need to allocate another block_list */
339
339
fl -> next = kmem_cache_zalloc (flash_block_cache , GFP_KERNEL );
340
340
if (!fl -> next )
341
- goto nomem ;
341
+ return - ENOMEM ;
342
342
fl = fl -> next ;
343
343
next_free = 0 ;
344
344
}
@@ -347,25 +347,17 @@ static ssize_t rtas_flash_write(struct file *file, const char __user *buffer,
347
347
count = RTAS_BLK_SIZE ;
348
348
p = kmem_cache_zalloc (flash_block_cache , GFP_KERNEL );
349
349
if (!p )
350
- goto nomem ;
350
+ return - ENOMEM ;
351
351
352
352
if (copy_from_user (p , buffer , count )) {
353
353
kmem_cache_free (flash_block_cache , p );
354
- rc = - EFAULT ;
355
- goto error ;
354
+ return - EFAULT ;
356
355
}
357
356
fl -> blocks [next_free ].data = p ;
358
357
fl -> blocks [next_free ].length = count ;
359
358
fl -> num_blocks ++ ;
360
- out :
361
- mutex_unlock (& rtas_update_flash_mutex );
362
- return count ;
363
359
364
- nomem :
365
- rc = - ENOMEM ;
366
- error :
367
- mutex_unlock (& rtas_update_flash_mutex );
368
- return rc ;
360
+ return count ;
369
361
}
370
362
371
363
/*
@@ -405,38 +397,30 @@ static ssize_t manage_flash_write(struct file *file, const char __user *buf,
405
397
static const char reject_str [] = "0" ;
406
398
static const char commit_str [] = "1" ;
407
399
char stkbuf [10 ];
408
- int op , rc ;
400
+ int op ;
409
401
410
- mutex_lock (& rtas_manage_flash_mutex );
402
+ guard ( mutex ) (& rtas_manage_flash_mutex );
411
403
412
404
if ((args_buf -> status == MANAGE_AUTH ) || (count == 0 ))
413
- goto out ;
405
+ return count ;
414
406
415
407
op = -1 ;
416
408
if (buf ) {
417
409
if (count > 9 ) count = 9 ;
418
- rc = - EFAULT ;
419
410
if (copy_from_user (stkbuf , buf , count ))
420
- goto error ;
411
+ return - EFAULT ;
421
412
if (strncmp (stkbuf , reject_str , strlen (reject_str )) == 0 )
422
413
op = RTAS_REJECT_TMP_IMG ;
423
414
else if (strncmp (stkbuf , commit_str , strlen (commit_str )) == 0 )
424
415
op = RTAS_COMMIT_TMP_IMG ;
425
416
}
426
417
427
418
if (op == -1 ) { /* buf is empty, or contains invalid string */
428
- rc = - EINVAL ;
429
- goto error ;
419
+ return - EINVAL ;
430
420
}
431
421
432
422
manage_flash (args_buf , op );
433
- out :
434
- mutex_unlock (& rtas_manage_flash_mutex );
435
423
return count ;
436
-
437
- error :
438
- mutex_unlock (& rtas_manage_flash_mutex );
439
- return rc ;
440
424
}
441
425
442
426
/*
@@ -499,16 +483,14 @@ static ssize_t validate_flash_write(struct file *file, const char __user *buf,
499
483
{
500
484
struct rtas_validate_flash_t * const args_buf =
501
485
& rtas_validate_flash_data ;
502
- int rc ;
503
486
504
- mutex_lock (& rtas_validate_flash_mutex );
487
+ guard ( mutex ) (& rtas_validate_flash_mutex );
505
488
506
489
/* We are only interested in the first 4K of the
507
490
* candidate image */
508
491
if ((* off >= VALIDATE_BUF_SIZE ) ||
509
492
(args_buf -> status == VALIDATE_AUTH )) {
510
493
* off += count ;
511
- mutex_unlock (& rtas_validate_flash_mutex );
512
494
return count ;
513
495
}
514
496
@@ -519,20 +501,14 @@ static ssize_t validate_flash_write(struct file *file, const char __user *buf,
519
501
args_buf -> status = VALIDATE_INCOMPLETE ;
520
502
}
521
503
522
- if (!access_ok (buf , count )) {
523
- rc = - EFAULT ;
524
- goto done ;
525
- }
526
- if (copy_from_user (args_buf -> buf + * off , buf , count )) {
527
- rc = - EFAULT ;
528
- goto done ;
529
- }
504
+ if (!access_ok (buf , count ))
505
+ return - EFAULT ;
506
+
507
+ if (copy_from_user (args_buf -> buf + * off , buf , count ))
508
+ return - EFAULT ;
530
509
531
510
* off += count ;
532
- rc = count ;
533
- done :
534
- mutex_unlock (& rtas_validate_flash_mutex );
535
- return rc ;
511
+ return count ;
536
512
}
537
513
538
514
static int validate_flash_release (struct inode * inode , struct file * file )
0 commit comments