linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Wen Yang <wenyang@linux.alibaba.com>,
	Wolfram Sang <wsa@the-dreams.de>, Sasha Levin <sashal@kernel.org>,
	linux-i2c@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 20/21] i2c: core: fix use after free in of_i2c_notify
Date: Fri, 22 Nov 2019 14:49:30 -0500	[thread overview]
Message-ID: <20191122194931.24732-20-sashal@kernel.org> (raw)
In-Reply-To: <20191122194931.24732-1-sashal@kernel.org>

From: Wen Yang <wenyang@linux.alibaba.com>

[ 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 <wenyang@linux.alibaba.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 8d474bb1dc157..17d727e0b8424 100644
--- a/drivers/i2c/i2c-core-of.c
+++ b/drivers/i2c/i2c-core-of.c
@@ -238,14 +238,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


  parent reply	other threads:[~2019-11-22 19:52 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-22 19:49 [PATCH AUTOSEL 4.14 01/21] autofs: fix a leak in autofs_expire_indirect() Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 02/21] RDMA/hns: Correct the value of HNS_ROCE_HEM_CHUNK_LEN Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 03/21] xfrm: Fix memleak on xfrm state destroy Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 04/21] iwlwifi: pcie: don't consider IV len in A-MSDU Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 05/21] exportfs_decode_fh(): negative pinned may become positive without the parent locked Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 06/21] audit_get_nd(): don't unlock parent too early Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 07/21] NFC: nxp-nci: Fix NULL pointer dereference after I2C communication error Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 08/21] xfrm: release device reference for invalid state Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 09/21] Input: cyttsp4_core - fix use after free bug Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 10/21] sched/core: Avoid spurious lock dependencies Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 11/21] ALSA: pcm: Fix stream lock usage in snd_pcm_period_elapsed() Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 12/21] net: usb: qmi_wwan: add support for Foxconn T77W968 LTE modules Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 13/21] slip: Fix memory leak in slip_open error path Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 14/21] net: cdc_ncm: Signedness bug in cdc_ncm_set_dgram_size() Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 15/21] slcan: Fix memory leak in error path Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 16/21] rsxx: add missed destroy_workqueue calls in remove Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 17/21] ax88172a: fix information leak on short answers Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 18/21] net: ep93xx_eth: fix mismatch of request_mem_region in remove Sasha Levin
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 19/21] i2c: acpi: Force bus speed to 400KHz if a Silead touchscreen is present Sasha Levin
2019-11-22 19:49 ` Sasha Levin [this message]
2019-11-22 19:49 ` [PATCH AUTOSEL 4.14 21/21] Input: synaptics - enable RMI mode for X1 Extreme 2nd Generation Sasha Levin
2019-11-22 19:56   ` Dmitry Torokhov
2019-11-25 13:34     ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191122194931.24732-20-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=wenyang@linux.alibaba.com \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).