Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp9318358ybc; Sat, 30 Nov 2019 05:12:05 -0800 (PST) X-Google-Smtp-Source: APXvYqyoAlqjBaNRos+Lrm5TatB5pg0M9eyR++VXBBrMXCloNbWhOK1H4rVCkmgOTQgPCXAepuhZ X-Received: by 2002:a17:906:2ad8:: with SMTP id m24mr19689724eje.180.1575119525425; Sat, 30 Nov 2019 05:12:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575119525; cv=none; d=google.com; s=arc-20160816; b=LfAmYAafAIzIHaWOE9P7ObVzja2clUd3aGnOGygta2oScquT4fDRWY7cbeqJmqsKiG OJ3duJxYZhTp8i6Mbf2jYs6n660Gbf6IGbLq96Ii1e3+X6uwa5RH3PKkCsoN+94Scayk bC1Ae0tAUO2Yoo6dR/vda7DhT498c40w2lKSbWoEqtklyqAmqqENmG10ob1pFZR2jCjZ qYTy6NqqWU8dHO+Tx3msVZ5+36x5bSS0ORd0m13E3FwMcN0ncwnvd7nwNnyJPNkx7Gql RK4Bx31ZNn900MtTzHrkK3U37/SSCdTOtfJaHnczyznDHemm4U/SwMh0PfRMMWGXuZjU 9UNg== 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=s0I3nbpOhpq5Y7Uk4xMKAOsMBt20iX5X9seNScnX2+I=; b=bkhfbJQ/gpG34CJJqJw/NEGvSkTJHklaOPFSqSeG9I/W4sT3Rt/+aRSxRHOnAy4iiu iqSbQaNEoukEeE8g1twy1TrJwk9Od2hxHne+9IAWYaEEekOyuh+2L7qaD4LuIXdrFKU0 hcCNQLm2b+xmXbGMLiGmMP2SPySq6wPhiwPez1F1oS4HZowgq9PxbEWfBcYsaZUS7XCX elze+4j6xDCAyuHOaKS3i1FVK7lFaxdcgQ+kyO9taP9x+oPPbdyKrzeIf5QPYyoq+6w4 ykyKlAKcpfEdabL6llOhcalp+xFfRf5c3FzwEkdz7UcqCQaXq+B2oXZGKOM/0A3ZaUbA ofOQ== 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 d12si5836828edr.279.2019.11.30.05.11.29; Sat, 30 Nov 2019 05:12:05 -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 S1726385AbfK3NI7 (ORCPT + 99 others); Sat, 30 Nov 2019 08:08:59 -0500 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:49697 "EHLO out30-57.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbfK3NI7 (ORCPT ); Sat, 30 Nov 2019 08:08:59 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R771e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04420;MF=wenyang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0TjTzGDP_1575119329; Received: from localhost(mailfrom:wenyang@linux.alibaba.com fp:SMTPD_---0TjTzGDP_1575119329) by smtp.aliyun-inc.com(127.0.0.1); Sat, 30 Nov 2019 21:08:56 +0800 From: Wen Yang To: Benson Leung , Enric Balletbo i Serra Cc: xlpang@linux.alibaba.com, Wen Yang , Nick Crews , linux-kernel@vger.kernel.org Subject: [PATCH] platform/chrome: wilco_ec: fix use after free issue Date: Sat, 30 Nov 2019 21:08:42 +0800 Message-Id: <20191130130842.33763-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 This is caused by dereferencing 'dev_data' after put_device() in the telem_device_remove() function. This patch just moves the put_device() down a bit to avoid this issue. Fixes: 1210d1e6bad1 ("platform/chrome: wilco_ec: Add telemetry char device interface") Signed-off-by: Wen Yang Cc: Benson Leung Cc: Enric Balletbo i Serra Cc: Nick Crews Cc: linux-kernel@vger.kernel.org --- drivers/platform/chrome/wilco_ec/telemetry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/chrome/wilco_ec/telemetry.c b/drivers/platform/chrome/wilco_ec/telemetry.c index b9d03c3..1176d54 100644 --- a/drivers/platform/chrome/wilco_ec/telemetry.c +++ b/drivers/platform/chrome/wilco_ec/telemetry.c @@ -406,8 +406,8 @@ static int telem_device_remove(struct platform_device *pdev) struct telem_device_data *dev_data = platform_get_drvdata(pdev); cdev_device_del(&dev_data->cdev, &dev_data->dev); - put_device(&dev_data->dev); ida_simple_remove(&telem_ida, MINOR(dev_data->dev.devt)); + put_device(&dev_data->dev); return 0; } -- 1.8.3.1