@@ -653,8 +653,8 @@ static int read_rom(struct fw_device *device, int generation, int speed, int ind
653653static int read_config_rom (struct fw_device * device , int generation )
654654{
655655 struct fw_card * card = device -> card ;
656- const u32 * old_rom , * new_rom ;
657- u32 * rom , * stack ;
656+ const u32 * new_rom , * old_rom __free ( kfree ) = NULL ;
657+ u32 * stack , * rom __free ( kfree ) = NULL ;
658658 u32 sp , key ;
659659 int i , end , length , ret , speed ;
660660 int quirks ;
@@ -673,7 +673,7 @@ static int read_config_rom(struct fw_device *device, int generation)
673673 for (i = 0 ; i < 5 ; i ++ ) {
674674 ret = read_rom (device , generation , speed , i , & rom [i ]);
675675 if (ret != RCODE_COMPLETE )
676- goto out ;
676+ return ret ;
677677 /*
678678 * As per IEEE1212 7.2, during initialization, devices can
679679 * reply with a 0 for the first quadlet of the config
@@ -682,10 +682,8 @@ static int read_config_rom(struct fw_device *device, int generation)
682682 * harddisk). In that case we just fail, and the
683683 * retry mechanism will try again later.
684684 */
685- if (i == 0 && rom [i ] == 0 ) {
686- ret = RCODE_BUSY ;
687- goto out ;
688- }
685+ if (i == 0 && rom [i ] == 0 )
686+ return RCODE_BUSY ;
689687 }
690688
691689 quirks = detect_quirks_by_bus_information_block (rom );
@@ -712,15 +710,13 @@ static int read_config_rom(struct fw_device *device, int generation)
712710 */
713711 key = stack [-- sp ];
714712 i = key & 0xffffff ;
715- if (WARN_ON (i >= MAX_CONFIG_ROM_SIZE )) {
716- ret = - ENXIO ;
717- goto out ;
718- }
713+ if (WARN_ON (i >= MAX_CONFIG_ROM_SIZE ))
714+ return - ENXIO ;
719715
720716 /* Read header quadlet for the block to get the length. */
721717 ret = read_rom (device , generation , speed , i , & rom [i ]);
722718 if (ret != RCODE_COMPLETE )
723- goto out ;
719+ return ret ;
724720 end = i + (rom [i ] >> 16 ) + 1 ;
725721 if (end > MAX_CONFIG_ROM_SIZE ) {
726722 /*
@@ -744,7 +740,7 @@ static int read_config_rom(struct fw_device *device, int generation)
744740 for (; i < end ; i ++ ) {
745741 ret = read_rom (device , generation , speed , i , & rom [i ]);
746742 if (ret != RCODE_COMPLETE )
747- goto out ;
743+ return ret ;
748744
749745 if ((key >> 30 ) != 3 || (rom [i ] >> 30 ) < 2 )
750746 continue ;
@@ -804,25 +800,19 @@ static int read_config_rom(struct fw_device *device, int generation)
804800
805801 old_rom = device -> config_rom ;
806802 new_rom = kmemdup (rom , length * 4 , GFP_KERNEL );
807- if (new_rom == NULL ) {
808- ret = - ENOMEM ;
809- goto out ;
810- }
803+ if (new_rom == NULL )
804+ return - ENOMEM ;
811805
812806 scoped_guard (rwsem_write , & fw_device_rwsem ) {
813807 device -> config_rom = new_rom ;
814808 device -> config_rom_length = length ;
815809 }
816810
817- kfree (old_rom );
818- ret = RCODE_COMPLETE ;
819811 device -> max_rec = rom [2 ] >> 12 & 0xf ;
820812 device -> cmc = rom [2 ] >> 30 & 1 ;
821813 device -> irmc = rom [2 ] >> 31 & 1 ;
822- out :
823- kfree (rom );
824814
825- return ret ;
815+ return RCODE_COMPLETE ;
826816}
827817
828818static void fw_unit_release (struct device * dev )
0 commit comments