Skip to content

Commit 781813d

Browse files
geertuWolfram Sang
authored andcommitted
i2c: core: Allocate temporary client dynamically
drivers/i2c/i2c-core-base.c: In function ‘i2c_detect.isra’: drivers/i2c/i2c-core-base.c:2544:1: warning: the frame size of 1312 bytes is larger than 1024 bytes [-Wframe-larger-than=] 2544 | } | ^ Fix this by allocating the temporary client structure dynamically, as it is a rather large structure (1216 bytes, depending on kernel config). This is basically a revert of the to-be-fixed commit with some checkpatch improvements. Fixes: 735668f ("i2c: core: Allocate temp client on the stack in i2c_detect") Signed-off-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Su Hui <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> [wsa: updated commit message, merged tags from similar patch] Signed-off-by: Wolfram Sang <[email protected]>
1 parent 0ad2507 commit 781813d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/i2c/i2c-core-base.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,7 +2506,7 @@ static int i2c_detect_address(struct i2c_client *temp_client,
25062506
static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver)
25072507
{
25082508
const unsigned short *address_list;
2509-
struct i2c_client temp_client;
2509+
struct i2c_client *temp_client;
25102510
int i, err = 0;
25112511

25122512
address_list = driver->address_list;
@@ -2527,19 +2527,24 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver)
25272527
return 0;
25282528

25292529
/* Set up a temporary client to help detect callback */
2530-
memset(&temp_client, 0, sizeof(temp_client));
2531-
temp_client.adapter = adapter;
2530+
temp_client = kzalloc(sizeof(*temp_client), GFP_KERNEL);
2531+
if (!temp_client)
2532+
return -ENOMEM;
2533+
2534+
temp_client->adapter = adapter;
25322535

25332536
for (i = 0; address_list[i] != I2C_CLIENT_END; i += 1) {
25342537
dev_dbg(&adapter->dev,
25352538
"found normal entry for adapter %d, addr 0x%02x\n",
25362539
i2c_adapter_id(adapter), address_list[i]);
2537-
temp_client.addr = address_list[i];
2538-
err = i2c_detect_address(&temp_client, driver);
2540+
temp_client->addr = address_list[i];
2541+
err = i2c_detect_address(temp_client, driver);
25392542
if (unlikely(err))
25402543
break;
25412544
}
25422545

2546+
kfree(temp_client);
2547+
25432548
return err;
25442549
}
25452550

0 commit comments

Comments
 (0)