Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3730622pxb; Mon, 24 Jan 2022 16:34:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqtusuynsB+ot8uu7psDbXnGiGHhTowXRuleSxa3v2GUsoNYrW6yRwZNIGKKUMrYl7oTi2 X-Received: by 2002:a17:90a:e7ce:: with SMTP id kb14mr815066pjb.202.1643070840712; Mon, 24 Jan 2022 16:34:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643070840; cv=none; d=google.com; s=arc-20160816; b=VhNyT0e8mSpU+OipeW8OERMpSKswh0HKiJNnUqUowb+HZrt6nLRv1QuBNAAuxnkWiG +4M50og53K2cA5btQ8ZGci78moksReaSgH0mAsfljxLLDzuwCAgoCQW3lhayFniVJhei ndxTh31CQwZ3Gzk8tI18T7HKn6Tls4t16rearwsXFGgfLw9AaSGcEvi7M5c/20rGuC4U ViPngWg7uWRuFyc3KaP0duDO2ZgjHYjkF0dbvbLe0H3w9X8FmmSQvyVkfni0FCxBrT1v VeBlp+Q5uGcSEFKDiB9j+F3E+bKBrVTfRuxWaWsgXGhp72J98jZXqI1x6DiJpc3cAuAr Q4pQ== 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=cTsDHcQs5RPAVHzv6icOCN2uVKiw8ZaLVBo4+98riNI=; b=m42TQirgeQM/oBKjve6ZKMaMNiLHEResm+4fxcljmA2eQjdAr18pdAOfsu+OKoVafa fk41pQcC1O4LmHfaNBDObYdqri/eUlcSG2WFkr03qccspFiQbJqvssrwUN5n3ocN+sMF oD175pE04Yw6qhRx0A3WWz/Cx13+TsHbxA9mx8KlSG0EN0WYd7OhfIIOxeuTgJMI4w5L SiwrXHMcxazYU2bBpD6E9zLHg0xMBAEJwFR+nrT+5xk0DLulGZIrkPUKX5Nl6sbamuk/ tQu0FYYq0M76RIYk48Vkyv4d49f5bBqSkNs+E3kX3+x02zcKpmt6cpk+z2vu2T8EE62G nJ2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bs7hmTmo; 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 v8si7667312pgi.789.2022.01.24.16.33.48; Mon, 24 Jan 2022 16:34:00 -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=bs7hmTmo; 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 S3411025AbiAYAba (ORCPT + 99 others); Mon, 24 Jan 2022 19:31:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1450655AbiAXVyz (ORCPT ); Mon, 24 Jan 2022 16:54:55 -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 CCB0AC0C0918; Mon, 24 Jan 2022 12:35:18 -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 89771B81229; Mon, 24 Jan 2022 20:35:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5F62C340E5; Mon, 24 Jan 2022 20:35:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056516; bh=hEOXtMUwE/45Nh6ai1hbQxYP2KFHIOMKiavrEhac3jM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bs7hmTmoQcWs3UOu31C0PGEHAFLzXggmP4KYbc0N/UKosNTGhAa/s6DOSu4uk4+8w bJSMzUky2IXJ0DD3T0orkGF+YhyuqHDdfeiYVwqtRBLGE7VnoGrsyXpPyq9yu7tRJN yc5xQhTWODbFHHJQ66XrI0iA/NsDvdmKQ/tMed8A= 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 5.15 503/846] HSI: core: Fix return freed object in hsi_new_client Date: Mon, 24 Jan 2022 19:40:20 +0100 Message-Id: <20220124184118.382937712@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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 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