Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3547601pxb; Mon, 24 Jan 2022 11:57:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLZaOe4denvjjX/osCA3eZ9FVb+feN7MKgQFX2SgJTZDX/MiepCvqqxL8yLNbg9UEFR4Ax X-Received: by 2002:a17:90b:3ec9:: with SMTP id rm9mr3497667pjb.142.1643054246549; Mon, 24 Jan 2022 11:57:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054246; cv=none; d=google.com; s=arc-20160816; b=EBVNYONC/AgL8i36pig4bM64LcYfAqPuKPOlR1/PdRBkSjiLvR59I1jSzWk79gPBQL 64CUTgVQpPOaTOXJIUY5BBoS0J6RlgT8b8HdxWnRCgbvEzT45fY3z52CufGwQT1/58cu lBhA5ypn3RRZUisns9lJDI144pavxlLkd3h4u6Is+6ULBJDQr75TgW1mpkCXngXhk/gZ g/NW9k2F3LY2Tbh1VpE02KaThBV4pKDKi/z+ZIaHUG4erSt8DolxtlimyryHo8IatvPA k6ljJNCIs2h9LRAT/3EW/kWAjqJ0B/E/P4PA63cPtk64ELcN7VnSclNbne+x8OEuVhrl vp/w== 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=j/MdQl3xwUrO2mYv5oIUjhKZPbZbhR7CKHXTVl/kmnU=; b=vAOqA/aWHtSs9xbykMqb48ynW2fVd/w4Ub6d5i0WNj1PH6xMN9TRBCiQRoVX9iM9gg GTqyMVYmYjJv4IkQjuvKSSfk1aUC3ZiQq6CDxbW2tCAMTfJxQ1swsIu30NXBZXH4BSUo LvtnpSk3o2oLxOurl/y6pZQ9PYmXvMQt8hcVaUofXac3IQ4ZUZZOTMxBCiMUia7eyvVR sstrMD/SVQZcgrpbSI1tRGogDAF715o88PsfIGbVQs7kPuA+aGvqRRmnoBQCSCMlZdhr eGP8BgE31PhFIiFU8+kPnsE0/QAXv72mHFSfTFqNkp+F7mCImtD1B0gdJAOqbEYrQT1R XOgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="yoM/w3la"; 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 e21si10385146pgj.698.2022.01.24.11.57.14; Mon, 24 Jan 2022 11:57:26 -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="yoM/w3la"; 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 S1343594AbiAXSwH (ORCPT + 99 others); Mon, 24 Jan 2022 13:52:07 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:49716 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343581AbiAXSvB (ORCPT ); Mon, 24 Jan 2022 13:51:01 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 8385561500; Mon, 24 Jan 2022 18:51:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40CEAC340E5; Mon, 24 Jan 2022 18:51:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050261; bh=ltfBF/t0KEK7VJPJMB0V8iusdFPJKGVQeC+PLK7eJGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yoM/w3laACBOuB7BhhLs1kSVlLYchWKnfjI0ebsFOjhzF6Uua1BKllnjJ7Hkko6we PrgxEt94D3UuHz9mgH9No2UQDcSlSpRLo3bHhOwtmlwUYAWOmYKhRS7OfT7it+k01G KHX8/KY8NX0eJH8nCEkmr4DUlhpdlizw03X56h/U= 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.4 062/114] HSI: core: Fix return freed object in hsi_new_client Date: Mon, 24 Jan 2022 19:42:37 +0100 Message-Id: <20220124183929.023202219@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183927.095545464@linuxfoundation.org> References: <20220124183927.095545464@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.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hsi/hsi.c b/drivers/hsi/hsi.c index 55e36fcd7ff35..e1080f005a19e 100644 --- a/drivers/hsi/hsi.c +++ b/drivers/hsi/hsi.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