From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 995113AC19 for ; Wed, 20 Sep 2023 12:31:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CE31C433C9; Wed, 20 Sep 2023 12:31:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695213075; bh=jDANtvcnF+vfV/gU6rPB9FFgIVWSMvb3YY9nCTFVGbw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ccuHhf7H8BQ4FQqsICnj/aFI7tqsfxLcX6rPFE8kiKwRECA04z+jDmCGwE0Gsv07y 5+22Ro8ux85T6IEMfzctxy+yPXj8wn3aOgSk0yd3DKdSuxKFfiTTCSMaH4lZOLW6Ib ZVDvOpT1b4uKX8pXgriA0Jfa5C0oksg4kM7YIn5E= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Corey Minyard , Sasha Levin Subject: [PATCH 5.4 126/367] ipmi:ssif: Fix a memory leak when scanning for an adapter Date: Wed, 20 Sep 2023 13:28:23 +0200 Message-ID: <20230920112901.932379619@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230920112858.471730572@linuxfoundation.org> References: <20230920112858.471730572@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Corey Minyard [ 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 Signed-off-by: Sasha Levin --- drivers/char/ipmi/ipmi_ssif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c index 0061f2207f318..a1b080dfa9604 100644 --- a/drivers/char/ipmi/ipmi_ssif.c +++ b/drivers/char/ipmi/ipmi_ssif.c @@ -1410,7 +1410,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); -- 2.40.1