Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3385573pxb; Mon, 17 Jan 2022 19:16:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+VC61nvJDq6m9tl1DPY8gDojO3JrK47LcucDRLs0xKm4qSxQNy6cnfWoVfhmzVndaFXHj X-Received: by 2002:a17:90b:3910:: with SMTP id ob16mr23398478pjb.88.1642475790639; Mon, 17 Jan 2022 19:16:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642475790; cv=none; d=google.com; s=arc-20160816; b=HtFnPx2b+UqdSJe4q/XKu5sdfmpreAJiPMQECP6E8hNDxOBo6p2sFxx59TMIzjIjXh wQkn63YeHaqePG7aHSD32aVkHW8o79PJtcEiDJFOLuuq2+yPQ/BjxqGlbtsaeOpEHWXt QvMnHQCMN3X4fjzL4YDHhK0WfKhiVP+9OV6U9ZRNKhBjjGtG3XTiEOQ8IEFDxdDbtadN okIMdDePozAYZkhZqTSpDjt4pW2coF19JMg9U0GTN4R/aX3DPFM20Jq1U+2dQ0Kzr/zz Zn5pVdP4KZAo0G8R4oQRLZcb3glfCrAZBK/QQFMdpB72+drkw/oEXnyYJphpxCdK98Vs fTmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cTsDHcQs5RPAVHzv6icOCN2uVKiw8ZaLVBo4+98riNI=; b=eP3Iu65VdtvoTZOU/t3W0oLxnQjmQG/160ls8yeX2NoxAsP7e9cwHr22fVnSJHYsim m7R2omngEIm7PtSED+UWTnuTZ3oyjvTitDmSkiXdHpzHQdzNcaR7d1BtrfNQ7eFphQZ8 2ny6U1OuA226GUlxkkMVJJfwOWzDLs+5excb7E0ou9FQQj5tQ6WHaPZFI+IvLQCGGjYd InrLNQqMxJ0r9QCmNgvcwkHFmG2PbDZS9JTGvOqtvRWCX1hFvPDM46zF29MNBTKcgk3d ELTA16cnYMAg4fLanX5FEHmmNh3513aEBRLgqCLa3CYCgz4zDDiDd8g4ejoBM+qlBdOp CE0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P8eYJUbd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lp18si1343206pjb.165.2022.01.17.19.16.17; Mon, 17 Jan 2022 19:16:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P8eYJUbd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244903AbiARCZd (ORCPT + 99 others); Mon, 17 Jan 2022 21:25:33 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:37908 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245321AbiARCXh (ORCPT ); Mon, 17 Jan 2022 21:23:37 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4A207B81238; Tue, 18 Jan 2022 02:23:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 660C1C36AEB; Tue, 18 Jan 2022 02:23:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642472615; bh=hEOXtMUwE/45Nh6ai1hbQxYP2KFHIOMKiavrEhac3jM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P8eYJUbd/jEF0mO1uZJ7rgl+TTrEq53jm9MGkJXqkF752OY2LyHu6RsNNar8Lq73l BVX405gG02xN2WB0C8IStRI7ys2uyhfP43Zv1gpQHBhDV7gQXVE+fJodtwfLovRNQY EfAGYF1M/ASmv+wN+rCNaBdvrS4Rtz1UY5Uh++wEEhlKI5W2K0bMCKT9YKEph4L/5n KYRDMIMBRQv7EaAxo67bFfXMhevc6bOpVcbDJ2u9Zihyqw2zXrAi2LZ6FVuSn2ZHcY rq2T/I3D745HDPqn5OM9r2ZSwbBDfCBj1DtRwi1pl7h4cM8grtA72juiMe31DnaYV5 SHqCJ86LYmGYA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Chengfeng Ye , Sebastian Reichel , Sasha Levin , sre@kernel.org Subject: [PATCH AUTOSEL 5.16 072/217] HSI: core: Fix return freed object in hsi_new_client Date: Mon, 17 Jan 2022 21:17:15 -0500 Message-Id: <20220118021940.1942199-72-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118021940.1942199-1-sashal@kernel.org> References: <20220118021940.1942199-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chengfeng Ye [ Upstream commit a1ee1c08fcd5af03187dcd41dcab12fd5b379555 ] cl is freed on error of calling device_register, but this object is return later, which will cause uaf issue. Fix it by return NULL on error. Signed-off-by: Chengfeng Ye Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/hsi/hsi_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hsi/hsi_core.c b/drivers/hsi/hsi_core.c index ec90713564e32..884066109699c 100644 --- a/drivers/hsi/hsi_core.c +++ b/drivers/hsi/hsi_core.c @@ -102,6 +102,7 @@ struct hsi_client *hsi_new_client(struct hsi_port *port, if (device_register(&cl->device) < 0) { pr_err("hsi: failed to register client: %s\n", info->name); put_device(&cl->device); + goto err; } return cl; -- 2.34.1