Skip to content

Commit 58aaa54

Browse files
author
Stefan Richter
committed
firewire: core: increase stack size of config ROM reader
The stack size of 16 was artificially chosen and may be too small in extreme cases. A device won't be accessible then. Since it doesn't really matter to the slab allocator whether we ask for 1088 bytes or 2048 bytes of scratch memory, just allocate 2048 bytes for the sum of temporary config ROM image and stack, and we will never ever overflow the stack (because there simply can't be more stack items than ROM entries). Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
1 parent 2799d5c commit 58aaa54

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎drivers/firewire/core-device.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,6 @@ static int read_rom(struct fw_device *device,
493493
}
494494

495495
#define READ_BIB_ROM_SIZE 256
496-
#define READ_BIB_STACK_SIZE 16
497496

498497
/*
499498
* Read the bus info block, perform a speed probe, and read all of the rest of
@@ -510,7 +509,7 @@ static int read_bus_info_block(struct fw_device *device, int generation)
510509
int i, end, length, ret = -1;
511510

512511
rom = kmalloc(sizeof(*rom) * READ_BIB_ROM_SIZE +
513-
sizeof(*stack) * READ_BIB_STACK_SIZE, GFP_KERNEL);
512+
sizeof(*stack) * READ_BIB_ROM_SIZE, GFP_KERNEL);
514513
if (rom == NULL)
515514
return -ENOMEM;
516515

@@ -612,8 +611,7 @@ static int read_bus_info_block(struct fw_device *device, int generation)
612611
RCODE_COMPLETE)
613612
goto out;
614613

615-
if ((key >> 30) != 3 || (rom[i] >> 30) < 2 ||
616-
sp >= READ_BIB_STACK_SIZE)
614+
if ((key >> 30) != 3 || (rom[i] >> 30) < 2)
617615
continue;
618616
/*
619617
* Offset points outside the ROM. May be a firmware

0 commit comments

Comments
 (0)