]> git.itanic.dy.fi Git - linux-stable/commit
i2c: mux: harden i2c_mux_alloc() against integer overflows
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 15 Sep 2022 11:30:58 +0000 (14:30 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Sep 2022 09:32:26 +0000 (11:32 +0200)
commit7f0dcbb0e5576b7a8232306c61334104a822ebf4
tree6c69d205b12d8740ae5d24277f2302ba2f2d0cac
parent4925e5e94ae9ff4dda3a59031354b5f4a75d7e41
i2c: mux: harden i2c_mux_alloc() against integer overflows

[ Upstream commit b7af938f4379a884f15713319648a7653497a907 ]

A couple years back we went through the kernel an automatically
converted size calculations to use struct_size() instead.  The
struct_size() calculation is protected against integer overflows.

However it does not make sense to use the result from struct_size()
for additional math operations as that would negate any safeness.

Fixes: 1f3b69b6b939 ("i2c: mux: Use struct_size() in devm_kzalloc()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Peter Rosin <peda@axentia.se>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/i2c/i2c-mux.c