ipmi: kcs_bmc: Fix a memory leak in the error handling path of 'kcs_bmc_serio_add_dev...
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Tue, 7 Sep 2021 21:06:32 +0000 (23:06 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Nov 2021 18:16:44 +0000 (19:16 +0100)
commitd6c25579a8a04862f9e4f0e55a458ea0815f3cc8
treef148666fc3ea1384fe0510f8e80eaa7c458eb3a9
parente8dabc670c402ed900c8ca502790321529839b73
ipmi: kcs_bmc: Fix a memory leak in the error handling path of 'kcs_bmc_serio_add_device()'

[ Upstream commit f281d010b87454e72475b668ad66e34961f744e0 ]

In the unlikely event where 'devm_kzalloc()' fails and 'kzalloc()'
succeeds, 'port' would be leaking.

Test each allocation separately to avoid the leak.

Fixes: 3a3d2f6a4c64 ("ipmi: kcs_bmc: Add serio adaptor")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Message-Id: <ecbfa15e94e64f4b878ecab1541ea46c74807670.1631048724.git.christophe.jaillet@wanadoo.fr>
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/char/ipmi/kcs_bmc_serio.c