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 93F83D528; Sun, 7 Sep 2025 20:27:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757276829; cv=none; b=HEu0mbdaS49dxS+ukOzaAR5/eOOrruPMDhcHoa8XQRvQonxNJZr2wZ6oPKbh3c2fxWfSNWozyVtD2ayl0qpzmJq/WR9bfv+B8yGDxGJYElDBtDkkdb9jKinC2xrvj11+t7uVuFMq+z1x+4ai5WMEtURsdmQCyG9EPePPUss+yZM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757276829; c=relaxed/simple; bh=QHJh/wHGERnZrwFjnlHEFRE5GOeT3UEQHpslYZ1/MYg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UWbK6CM83H0LEsHcruHRaZzvZa8E4uu/3nXHOj8fVfapfzHoA7pZCwdXGVyts2CZeveeyr21Dfk+05LQkWZRrmaXi71he0Aa8ROhb+cp7NGGCnKZTJ1bHTJfUYo45Zmyzet0DagzIYtL7KKeQMYeaWn8x5WEtF+G7sc4CznEcWI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=cXeRt/4B; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="cXeRt/4B" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19E11C4CEF0; Sun, 7 Sep 2025 20:27:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1757276829; bh=QHJh/wHGERnZrwFjnlHEFRE5GOeT3UEQHpslYZ1/MYg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cXeRt/4BkBh3tswd76XuH/4h8fhwTjL2St6JnYV15ULtVb98Hd3VIc3jyqRt8Yo38 a+EJCVt1ZY7i3Jw5Oci8Qyxqk3tpiszQdoTFjimLrln+fN8kwRzrrN4YcaI6ouHL3e m1gTIGfaOn4UH7+ziwgZ0G+/jbuXrSCuZ0KBVcZA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wentao Liang , Dominik Brodowski , Sasha Levin Subject: [PATCH 6.6 100/121] pcmcia: Add error handling for add_interval() in do_validate_mem() Date: Sun, 7 Sep 2025 21:58:56 +0200 Message-ID: <20250907195612.420254348@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250907195609.817339617@linuxfoundation.org> References: <20250907195609.817339617@linuxfoundation.org> User-Agent: quilt/0.68 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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wentao Liang [ Upstream commit 4a81f78caa53e0633cf311ca1526377d9bff7479 ] In the do_validate_mem(), the call to add_interval() does not handle errors. If kmalloc() fails in add_interval(), it could result in a null pointer being inserted into the linked list, leading to illegal memory access when sub_interval() is called next. This patch adds an error handling for the add_interval(). If add_interval() returns an error, the function will return early with the error code. Fixes: 7b4884ca8853 ("pcmcia: validate late-added resources") Signed-off-by: Wentao Liang Signed-off-by: Dominik Brodowski Signed-off-by: Sasha Levin --- drivers/pcmcia/rsrc_nonstatic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index bf9d070a44966..da494fe451baf 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c @@ -375,7 +375,9 @@ static int do_validate_mem(struct pcmcia_socket *s, if (validate && !s->fake_cis) { /* move it to the validated data set */ - add_interval(&s_data->mem_db_valid, base, size); + ret = add_interval(&s_data->mem_db_valid, base, size); + if (ret) + return ret; sub_interval(&s_data->mem_db, base, size); } -- 2.51.0