Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3564661pxb; Mon, 24 Jan 2022 12:19:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKmdB/KcEqEH+vDUSe6UuMQXoun5ujApLKNvdhxUAg+SxfyHYYa0iWaJnxr3UQ4btg5906 X-Received: by 2002:a17:902:7889:b0:14b:6182:a263 with SMTP id q9-20020a170902788900b0014b6182a263mr3130696pll.15.1643055582533; Mon, 24 Jan 2022 12:19:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643055582; cv=none; d=google.com; s=arc-20160816; b=RenWJsc7d3f9+uIFEMOUY0774xvR12nFxpUbexNIF7ZcNyrg4bNXL9ecCvbKJ/pVtK qY0Tn8y7VfibKGi/58grfcKt3AfGCnZzFKRL8t4E/uGgjsEEPn577w8lncI+UhTCTlIS 0Evta5yPotPtg1GD0hddn5sGQK42KOTTL4T0P2rQ4ZpWTgXNx3jMwJRA2TNlm1CbPuQg sGRkP1PzsRMBcJAoaej340VkheVU/gKolnGbveYzCrf/2BaStKxGsxiOvbYdpB1TEQWP iPan56OIDhUJFOFjW4cWKo4B2WxB3Jb3GM09ufEi5QxrdiZFrJOyH6JqPXn52ZhoVjB6 L0DQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ln3MxRGaMc98H/l5MfgtNXNTxlcG/fA+Es1J3xfQnxA=; b=NVft+uO9DI0JpZHtnlCZnAtU+nwRowEMQFcsF1RjIe/YOMm+RxcG3CwqGLsF/OOzKL 35+TYNSSFDoXdWGJTe4XUCTCOKbUCpxA81NOk4JnaP8Z/u7jI9297V8oD+litkTqb4ub mJLIKFvWXyf8wPjpS5j4wyCQk1CbL+8zFYwElZPLCi5+tauh+Ryy5NjBLQGsx2bDDRRU d2ts80yY7J+5oXwMkBbs9hgp+OPwH0PGVKAEaKpFlOg1oSpMytPzKplV2jeDkWf4PmPP 1bBTF0lIFgmHSE9IrEk74cbjk8gRFRaVSS0hC51QEyBAxTy470svGhWwnWMadyWG83wy zb4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wAQ3nMD0; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u9si17138351plh.339.2022.01.24.12.19.29; Mon, 24 Jan 2022 12:19:42 -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=@linuxfoundation.org header.s=korg header.b=wAQ3nMD0; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351199AbiAXT0K (ORCPT + 99 others); Mon, 24 Jan 2022 14:26:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347799AbiAXTSn (ORCPT ); Mon, 24 Jan 2022 14:18:43 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6085C09425D; Mon, 24 Jan 2022 11:07:17 -0800 (PST) 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 914EDB81238; Mon, 24 Jan 2022 19:07:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC477C340E5; Mon, 24 Jan 2022 19:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051235; bh=5AK/ZD+OO4TiPDAZvOFjQFvLrOlNWLTVM/ikSQ8BP24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wAQ3nMD06A5xCYTnsdKmPFybpr6iAVcg+LwqCmi+/Vodo4+TmiSgUmjMRDQ7Xidju QIV0oR11+uWjeMNPwlWOmh/YILuaxLBiHIy0SoYDBP2PcIAYqRQanseyqOFChcepQ3 OljslQ4sAsHCaApRjChy5jW75Sxiu6vChzR/J/4s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chengfeng Ye , Sebastian Reichel , Sasha Levin Subject: [PATCH 4.14 097/186] HSI: core: Fix return freed object in hsi_new_client Date: Mon, 24 Jan 2022 19:42:52 +0100 Message-Id: <20220124183940.237290348@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 71895da63810b..daf2de837a30a 100644 --- a/drivers/hsi/hsi_core.c +++ b/drivers/hsi/hsi_core.c @@ -115,6 +115,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