Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3642356pxb; Mon, 24 Jan 2022 14:13:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAgO9fRShmJ+i/OedDQJ04ayZ407dOt7bFz5BubvGhyjdjAnVuCUGtyfYWdVf65l1T5N0d X-Received: by 2002:aa7:9217:0:b0:4bd:140:626c with SMTP id 23-20020aa79217000000b004bd0140626cmr15255288pfo.7.1643062408945; Mon, 24 Jan 2022 14:13:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643062408; cv=none; d=google.com; s=arc-20160816; b=R2/i8jHhua9ea6H7YQ8NBNlnOhdA6Ab/eRicgOVoPxSEpPS1ZviFvmcOSwJ1T9JFOt jmXL5psXOm30AtYkJRjN3FAufcGVaRkODeSn91ehgasMfI3U5EVzoEFGjb+HcqogLhXg +tpGaasAC3afb4Tot4CpL9ieyYXEAVe3MwOr55Boo8fcwyGEYR4wyf39y5FXCYnTIeTs Y3qhGOMrWR6AXnF3ucA/jirnW11y/ef3bArPHGhlZSdzfTqfHpVtI9fRXCydtFMIISxP mDGNmM1Lpg7ya2WdLylsMmZAWAne071iLaSa5VMC5/EVNzpvBZRvwAlqwaGdaLZd+9BC LGNg== 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=ydlMEHWope2FR+/4xk1fN8L4+2TjrqvIW2zutIjetIcT22UFfSKupFV8x+PbCVBSUR 3+1mgZDsGKDbFp3jzrfOoUtA3857DDUQ5t2TjiCbVMJQxxcbFL+jWbnhEv+6k9/QXd2a mpT539/wJzv+kRfD43l6z4VUdrW6dUsOdnM3I7D0TPkH/G2ff10hiShdTYVuUTGWBM+v dxqq0TsUxjqF8NiwxdHn6iVC50IZbH9QWc7hqcbgoGYi+PkHo2epDtTGqpKwmC6FswUc Vm/c7kalubYJy24IgX/vHDOt3EhtQOHvB1lg+9KN3Gcul+qMgIk/gmn1dNRCFrr1lPIE iqdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f+QWbv9L; 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 ch22si525429pjb.2.2022.01.24.14.13.14; Mon, 24 Jan 2022 14:13:28 -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=f+QWbv9L; 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 S1577574AbiAXWAd (ORCPT + 99 others); Mon, 24 Jan 2022 17:00:33 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:40176 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1451404AbiAXVWy (ORCPT ); Mon, 24 Jan 2022 16:22:54 -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 2F873B8123D; Mon, 24 Jan 2022 21:22:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6193BC340E4; Mon, 24 Jan 2022 21:22:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059370; bh=hEOXtMUwE/45Nh6ai1hbQxYP2KFHIOMKiavrEhac3jM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f+QWbv9LSAA4Rqj/ZfSXb1kmYiGni+elscsL1Huc/gCXj9cxTSVklkF2cHI4BnsLH noryMqsxuTGjm2UjBirZJkhXc1YRoJzgKqSLwl2NSP2m7iWBr0cQSMiDP4FXVBQ7Qy EygRvyCU5klhfb6QlHej41mUm0LplN7BgrcbPa8U= 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.16 0594/1039] HSI: core: Fix return freed object in hsi_new_client Date: Mon, 24 Jan 2022 19:39:43 +0100 Message-Id: <20220124184145.299780465@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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