Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2165588ybx; Fri, 8 Nov 2019 00:38:17 -0800 (PST) X-Google-Smtp-Source: APXvYqw0RASmw7Ebr2VHrcYtwF9YvVqeSii6oIq/IKkliOFY+4ctacL3HBlZ56Z92jiM/qChiR8I X-Received: by 2002:a17:906:670c:: with SMTP id a12mr7442650ejp.273.1573202297713; Fri, 08 Nov 2019 00:38:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573202297; cv=none; d=google.com; s=arc-20160816; b=OQZQUWXNHx1M1s8U2073+Vok8Vic0n8jaZfErYnn5boZiBXq8aakN4s7B1B6p9P9Vy TC3IdZ0UF6SKb2N00kwTmU18P+1dzayu3xaq+NIe7u13W+TYKveJjT8lA16oX6gLphSD xZsS0uyfGS9eHwZ2rYBZuGdYFqQfNujz9+HofQ63qDb4zudWDIct2yyjNg9jqg3ArVuV wcaQi7kZWWoMoZyvyvYL4RWN4NaBY1d5+mmaEEmif8lJqrItZEqIb/3IbzcqRtjUedpW Dk5lCdN+WC5zV35JpUUOucz4EUJg1dAlZ/Tdw/TvnDLl5viceN8ezwotAQhQGMP+KP+o A7Cw== 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 :message-id:date:subject:cc:to:from; bh=1380avlPtaXrWweefTqS95Nb/xrAtQr858i+9Rxuwug=; b=Z0VXMlxVY/0X0PiyuTCsjst7SCtqC7u8ZbYdUOEe8Mxv++6POli/s/iFGVS6tia1KN tXr/sxymimzUCgMkHX4l0nQY0Zy3eGTbzHfKdPNKgHyPt2oIW3BGq7wS3AKTPXLJqja0 3fM/teDpdI6//2ddaijTQ/ByE+XMFhy0VoWVO9hCLJkE7VLDAHCIkKgBcrH3CmAUUQSj kfT8+Cx6lO4Io45Y9a0L0RpTgF2q/aZa0j4eRo7KP3v6P5MpErswVc7dYg8Rp4zLDtJY SDlvD7tL2lysQaU/pZylBveP+JOVIAUDCiOJ8fYHpwd3rzxE3kOFoJXiRRgobRQ/MAfz /9nw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a27si3855108edm.187.2019.11.08.00.37.53; Fri, 08 Nov 2019 00:38:17 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730463AbfKHIhD (ORCPT + 99 others); Fri, 8 Nov 2019 03:37:03 -0500 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:47986 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726987AbfKHIhD (ORCPT ); Fri, 8 Nov 2019 03:37:03 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=wenyang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0ThUQNT9_1573202209; Received: from localhost(mailfrom:wenyang@linux.alibaba.com fp:SMTPD_---0ThUQNT9_1573202209) by smtp.aliyun-inc.com(127.0.0.1); Fri, 08 Nov 2019 16:37:01 +0800 From: Wen Yang To: wsa@the-dreams.de Cc: zhiche.yy@alibaba-inc.com, xlpang@linux.alibaba.com, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Wen Yang Subject: [PATCH] i2c: core: fix use after free in of_i2c_notify Date: Fri, 8 Nov 2019 16:36:48 +0800 Message-Id: <20191108083648.56503-1-wenyang@linux.alibaba.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We can't use "adap" after it has been freed. Fixes: 5bf4fa7daea6 ("i2c: break out OF support into separate file") Signed-off-by: Wen Yang Cc: Wolfram Sang Cc: linux-i2c@vger.kernel.org Cc: linux-kernel@vger.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 6f632d54..7eb4199 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -245,14 +245,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? */ -- 1.8.3.1