Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp827791ybl; Wed, 11 Dec 2019 08:06:50 -0800 (PST) X-Google-Smtp-Source: APXvYqy33Yrq4MqXCXe6HUPygq9sYz8pU/UQG/OFXzF0Ju3RHD2HB5kb/qlRpJvAFt8P/SXq5uj3 X-Received: by 2002:aca:b7c5:: with SMTP id h188mr3462847oif.100.1576080409860; Wed, 11 Dec 2019 08:06:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576080409; cv=none; d=google.com; s=arc-20160816; b=ntqfH5W0v4LM0XlYgJk37rMeta02S8AkWrCjJRbFeJH+miI7Nx9cHTvzliWpaeZGzr AWoxz4QWNv01EKxjlOq1PwJaidWd7QnjhCV01gdts7wB9iLWG6b38QXqSaB91rIStZro Xde5tEicdjWVWZsYt++S5kiiEH91/nXRa8qpJacKkI0xgBbSSVnwcJGNNvDaj9TK2RCV dCjvRuVmWLiTc6nAIM1b1akDmU0o6CooRyPOTYVJJU8Cqa2yAWzLw9teOHU1rPYHJyv8 IDF2aUTEcTgil7yjfXnJO6+xxIGU5ccqF/0hTvQSusPl8WdsxKm9htvMq5UBvZmZnq5F ZC+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3uFRQ/scjRN8APgofTAwSBxErI0C6sM7tu0xIFSehh4=; b=QIZ+w2/VvXkkR7ue4vJHPpkV2MN+h46VEwltWOve+dW6uKCDOK3DTHxWyZ7yiSYb46 O1NVZZhDBOeaiP7XYveYIBdFMo3Kvwju4kfUjVyGHN5YxYccIiITbQlnK67/lJn1P1RZ zfOZX+BgWGxQH51pPCtyQub3NPvN/ctfQQEdRMtLp5YSQ3zihdWZfzh3bqF5L3Cxxuy6 wBPy1Xn0/Fu0xHS/xgHfjcaHA4RjGqtCwoTVcuvdsFQF46Akwondk9d0bLI3PncD2L5b GbOpcVH82KoVAUNoTDhnyMRgwLBfNfFjQCdOC0kiLrnQd/Qz+ph8cUObF77VwDW59WRd E/pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TUkoghti; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i124si1350035oif.214.2019.12.11.08.06.37; Wed, 11 Dec 2019 08:06:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TUkoghti; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732884AbfLKQFO (ORCPT + 99 others); Wed, 11 Dec 2019 11:05:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:35376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731252AbfLKPMy (ORCPT ); Wed, 11 Dec 2019 10:12:54 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 602BB24658; Wed, 11 Dec 2019 15:12:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576077173; bh=6FNxpNp+hoECWh0+kePorVfjimC+84RVOjnjeC0s1uw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TUkoghtiwHlIPopKBDHFb+GSA5EU9e/Z7qhay6R96U5gHWkwhNT3mQuernbc/pW6u 5rbZOFFQLUSaYaFaWf4QD+sPG7o9zr8TmY7c8yJ2lr+YjTNGT4S15bBiatVKN8ByxE TQWW30I4+Mgdg/G85MrSxIZIIx8iQs5XimLRT9lY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wen Yang , Wolfram Sang , Sasha Levin Subject: [PATCH 5.3 043/105] i2c: core: fix use after free in of_i2c_notify Date: Wed, 11 Dec 2019 16:05:32 +0100 Message-Id: <20191211150238.151620396@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191211150221.153659747@linuxfoundation.org> References: <20191211150221.153659747@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wen Yang [ Upstream commit a4c2fec16f5e6a5fee4865e6e0e91e2bc2d10f37 ] We can't use "adap->dev" after it has been freed. Fixes: 5bf4fa7daea6 ("i2c: break out OF support into separate file") Signed-off-by: Wen Yang Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/i2c-core-of.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index d1c48dec7118e..9b2fce4906c41 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -250,14 +250,14 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action, } client = of_i2c_register_device(adap, rd->dn); - put_device(&adap->dev); - if (IS_ERR(client)) { dev_err(&adap->dev, "failed to create client for '%pOF'\n", rd->dn); + put_device(&adap->dev); of_node_clear_flag(rd->dn, OF_POPULATED); return notifier_from_errno(PTR_ERR(client)); } + put_device(&adap->dev); break; case OF_RECONFIG_CHANGE_REMOVE: /* already depopulated? */ -- 2.20.1