ipmi: ipmb: don't allocate i2c_client on stack
authorArnd Bergmann <arnd@arndb.de>
Wed, 19 Jun 2019 12:50:34 +0000 (14:50 +0200)
committerCorey Minyard <cminyard@mvista.com>
Wed, 19 Jun 2019 14:03:55 +0000 (09:03 -0500)
commit21feadd024e747123bc0aaba8d8cbef2b5eda058
tree9b63a17c5f17e7aa82f0f1b2ecf6aa1c51f1e73d
parent102308f557bca8e539a800614b0e274945a81cdf
ipmi: ipmb: don't allocate i2c_client on stack

The i2c_client structure can be fairly large, which leads to
a warning about possible kernel stack overflow in some
configurations:

drivers/char/ipmi/ipmb_dev_int.c:115:16: error: stack frame size of 1032 bytes in function 'ipmb_write' [-Werror,-Wframe-larger-than=]

There is no real reason to even declare an i2c_client, as we can simply
call i2c_smbus_xfer() directly instead of the i2c_smbus_write_block_data()
wrapper.

Convert the ipmb_write() to use an open-coded i2c_smbus_write_block_data()
here, without changing the behavior.

It seems that there is another problem with this implementation;
when user space passes a length of more than I2C_SMBUS_BLOCK_MAX
bytes, all the rest is silently ignored. This should probably be
addressed in a separate patch, but I don't know what the intended
behavior is here.

Fixes: 51bd6f291583 ("Add support for IPMB driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Message-Id: <20190619125045.918700-1-arnd@arndb.de>
Acked-by: Asmaa Mnebhi <Asmaa@mellanox.com>
[Broke up a line >80 characters on i2c_smbus_xfer().]
Signed-off-by: Corey Minyard <cminyard@mvista.com>
drivers/char/ipmi/ipmb_dev_int.c