]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ipmi:ssif: Fix a memory leak when scanning for an adapter
authorCorey Minyard <minyard@acm.org>
Mon, 19 Jun 2023 16:43:33 +0000 (11:43 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Sep 2023 07:48:19 +0000 (09:48 +0200)
[ Upstream commit b8d72e32e1453d37ee5c8a219f24e7eeadc471ef ]

The adapter scan ssif_info_find() sets info->adapter_name if the adapter
info came from SMBIOS, as it's not set in that case.  However, this
function can be called more than once, and it will leak the adapter name
if it had already been set.  So check for NULL before setting it.

Fixes: c4436c9149c5 ("ipmi_ssif: avoid registering duplicate ssif interface")
Signed-off-by: Corey Minyard <minyard@acm.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/char/ipmi/ipmi_ssif.c

index 3b87a2726e9940f3bff46e46e512feee5c9ef95d..faf1f2ad584bfc5a358860150327446101ad15de 100644 (file)
@@ -1400,7 +1400,7 @@ static struct ssif_addr_info *ssif_info_find(unsigned short addr,
 restart:
        list_for_each_entry(info, &ssif_infos, link) {
                if (info->binfo.addr == addr) {
-                       if (info->addr_src == SI_SMBIOS)
+                       if (info->addr_src == SI_SMBIOS && !info->adapter_name)
                                info->adapter_name = kstrdup(adapter_name,
                                                             GFP_KERNEL);