Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3600606pxb; Mon, 24 Jan 2022 13:13:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJyeg8qjFS7Rh8QVUVYu6lIM9SPGB6A4RGGxGZ9XR0ano5lZdWNtCWbMnorsq9mGIYziq3jo X-Received: by 2002:a17:902:700a:b0:14b:7484:9866 with SMTP id y10-20020a170902700a00b0014b74849866mr268786plk.172.1643058836878; Mon, 24 Jan 2022 13:13:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643058836; cv=none; d=google.com; s=arc-20160816; b=S4YeAzkrM5+GwrRoP5a3Iw55qLNpUcmXG+hjFipffp8xCYfBr0w9h1qR9x8cQItdnj v0aNnnZXMIVq+kdpcTfWEA/qAG7PXdv8Cb4EpqI+L1lOknIOQRlXwQxTHvFMzS8VFr/c 8TEcSq0TvXtACyMyfX0/4ZxZD58zuWe8TvRtQypLi7fkpeoG5gnrY7kZsvxhwtpeLVGE 4SDKFkiBaRNU4frAcCPEP9A4mZjrt3HMskEVwOA1m4mH9U1i6nfZPs05hJnAvyoYLAyZ FnAYxSTvPCeZZOLgScuubvfPiYNsWuKMR7MSowy7QiKbkALtwuoGYQDEQpzdlEf6jGIL HIMA== 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=jY6UJ7dRgYpRPXZY7HpjCuHh1itwnP0j4fTh/vLGhvo=; b=kn38RN0Hpd0ASdlpnLXbw9ctCJMad5XJNfvRz3so2Lx0cb/YVYsHlYrO+j/OOVTm/q N2gp0BLUQZUVQ4IgGrcMqmCZ6Wm7MJSgug/AFkYhncAWbBeM7or9XTHOYck2BV+u9+LK mkn3WxyKCcka1H1NgMMs9QTuxEnYxd6xSuffj7qpwo3njewV1VEA5CbFK0EIUnqz14tG xAKBShFlwTIg3bXd/KoRnC6ewAH7Z6mQwa0ZrxV1D3X4irkZX62NuKFFB7O51ETrJUxY VGxCuOJqQDpCA4d4t789vDAPtEj+3bKKCk4obAkkme979VbayUKqz87a9m03LqgOciNA Asnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tp91cejA; 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 mi2si393517pjb.139.2022.01.24.13.13.44; Mon, 24 Jan 2022 13:13:56 -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=tp91cejA; 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 S1386587AbiAXUfm (ORCPT + 99 others); Mon, 24 Jan 2022 15:35:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355128AbiAXUNU (ORCPT ); Mon, 24 Jan 2022 15:13:20 -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 EE8A0C028C3E; Mon, 24 Jan 2022 11:34:19 -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 ABACAB811F9; Mon, 24 Jan 2022 19:34:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E622DC340E5; Mon, 24 Jan 2022 19:34:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052857; bh=SR6/RHYzbaW8Yv7fuCZxeBV3M2Vgut2hDG7UGkgolbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tp91cejAMrxQZDK/KtBJxVu9mu9DRKVwFVYrCkgzzSYnszt9iZ19aNPSusXxbgEMX 9DTbBIrazPmygi+2y84aXTFXXklwjwo3ReDZCwSjkHYFalSpJd/QEn/GSG4vUP5/Ib ZSWAIe1b5Jq1euU872/qDf9gEQli6geUJLwE73ys= 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.4 169/320] HSI: core: Fix return freed object in hsi_new_client Date: Mon, 24 Jan 2022 19:42:33 +0100 Message-Id: <20220124183959.418536720@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@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 a5f92e2889cb8..a330f58d45fc6 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