]> Gentwo Git Trees - linux/.git/commit
i2c: dev: Fix memory leak when underlying adapter does not support I2C
authorIgor Pylypiv <ipylypiv@google.com>
Fri, 8 Nov 2024 00:15:42 +0000 (00:15 +0000)
committerWolfram Sang <wsa+renesas@sang-engineering.com>
Thu, 14 Nov 2024 10:22:57 +0000 (11:22 +0100)
commit48730a9d04ffccda541602d722d1ff81920a85d8
tree67049c6dad15e6bbf8f4947ed1783f5617c10aa0
parent433c6916628e5e2ba47e618d96c23e8a9c5a6b9e
i2c: dev: Fix memory leak when underlying adapter does not support I2C

Early return in i2cdev_ioctl_rdwr() failed to free the memory allocated
by the caller. Move freeing the memory to the function where it has been
allocated to prevent similar leaks in the future.

Fixes: 97ca843f6ad3 ("i2c: dev: Check for I2C_FUNC_I2C before calling i2c_transfer")
Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
[wsa: replaced '== NULL' with '!']
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
drivers/i2c/i2c-dev.c