Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp10761613ybl; Fri, 27 Dec 2019 01:38:33 -0800 (PST) X-Google-Smtp-Source: APXvYqzdcdtWnbZLmTUOpQTwm1F2+WvEW3oGL5J/u1+74sgnrM2jtgfGXaXNxIJr93cS3DuL/GDR X-Received: by 2002:a9d:7501:: with SMTP id r1mr53846946otk.196.1577439513496; Fri, 27 Dec 2019 01:38:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577439513; cv=none; d=google.com; s=arc-20160816; b=auXcTnoa6ML4JpTXPCXL5B6R48FuIdvFdFxxcDpk5d6dlyqng7NZknPShXuvAZ8lHi cNmJScXLXdyj/3Qwp1BtRh5OGQZjr8btO/MfJv9tqHH/PWym3zIiM/wUhDzcnzP9U52n PWsusZgRNyJ214wl9LlJ/B3gEu5sLGgsIr4qlaq+w+/orWBp9iYIfMMOUC9OCGOj/lx0 kQTgcSGCeNrjZVFHagfE9KOG/Slg94aC7LQV64K+4CuOTSyKpBVuAGQb1zYp+plPFhjQ vYnd8pQDkTeNAFiJFZi9G4U9RWITubDHRzwaAGvbaWBgKEpuY18T/DHMBO0nxy7NnL1c kS7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=0ytDJOdFAM2mIFt7JznT+2FCqlgmngxjos+k3ovO7jM=; b=cOFVXg0pjTIf7QsdQqBDewYyKabo8ojjknqAmIAAIFvtGEczAFamIfx2ZRttrYlGTM a5lAnbBjUl6YnmZR2zLuasHXc+lZ1YWDpsGUFTuhHzBU+AzzspJHqfVWQF2+pth2YRFD TKvRSUSw5s3CoUAVVW7uRD6OytnPJKlTWSGiU1tN27TlIFS5WIn3MFb5lty51Am2QuTQ Xme0tBfDd6++qIUlwyD1nT01zrOYEybcYvjCvUXW8cXAGpoZrLNkCEbawyQGhkhDrNS6 ujxK/3rw9nIzhKcikS4X0my63NRXnwMGpgXf7E0CJEbAdX9+2KjUJWKoQrrWq66Iq+yb QMaA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4si17964528oto.169.2019.12.27.01.38.08; Fri, 27 Dec 2019 01:38:33 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726379AbfL0Jes (ORCPT + 99 others); Fri, 27 Dec 2019 04:34:48 -0500 Received: from smtp21.cstnet.cn ([159.226.251.21]:41072 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725904AbfL0Jer (ORCPT ); Fri, 27 Dec 2019 04:34:47 -0500 Received: from localhost.localdomain (unknown [159.226.5.100]) by APP-01 (Coremail) with SMTP id qwCowAB3fLgr0AVewOdMCg--.31S3; Fri, 27 Dec 2019 17:34:35 +0800 (CST) From: Xu Wang To: wsa@the-dreams.de Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] i2c: Fix a potential use after free Date: Fri, 27 Dec 2019 09:34:32 +0000 Message-Id: <1577439272-10362-1-git-send-email-vulab@iscas.ac.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: qwCowAB3fLgr0AVewOdMCg--.31S3 X-Coremail-Antispam: 1UD129KBjvdXoWrZr4kWF15Cr4UuryfGr43trb_yoWxZwbEka 4UA3ZrWr95Crs8ur15AFW5ZryrKFZYq39Y9w10qrZ3Aa4Ygr17WFWUZ3y3Ww4Ygr1DW3W3 W3WqgrWxX3sxZjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb28YjsxI4VWDJwAYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I 6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM2 8CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0 cI8IcVCY1x0267AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIE14v26F4UJVW0owA2z4x0Y4vEx4 A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IE w4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMc vjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCY02Avz4vE14v_GFWl42xK82IY c2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s 026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1Y6r17MIIYrxkI7VAKI48JMIIF 0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0x vE42xK8VAvwI8IcIk0rVWrJr0_WFyUJwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E 87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07joD73UUUUU= X-Originating-IP: [159.226.5.100] X-CM-SenderInfo: pyxotu46lvutnvoduhdfq/1tbiBgURA10TefpTAQAAsO Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Free the adap structure only after we are done using it. This patch just moves the put_device() down a bit to avoid the use after free. Signed-off-by: Xu Wang --- drivers/i2c/i2c-core-base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 9f8dcd3..160d43e 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -2301,8 +2301,8 @@ void i2c_put_adapter(struct i2c_adapter *adap) if (!adap) return; - put_device(&adap->dev); module_put(adap->owner); + put_device(&adap->dev); } EXPORT_SYMBOL(i2c_put_adapter); -- 2.7.4