Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp9138472ybc; Sat, 30 Nov 2019 01:37:53 -0800 (PST) X-Google-Smtp-Source: APXvYqxk1Al3VlOZMKMJUh4LivtflGUuti0svdBOQ1ctmadsjO+G9aHcouvF/6kiK3INuSKyAk4m X-Received: by 2002:a17:906:bc51:: with SMTP id s17mr598643ejv.137.1575106673641; Sat, 30 Nov 2019 01:37:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575106673; cv=none; d=google.com; s=arc-20160816; b=nQEgLqA3LZL4f++bpB3sPRJEqOK0LTH1Oj14qF/v91gQBBEr6M0mKyWFbem5V2YNBQ Q5oBIabegplDDcZqRnoAEq1dv6XviUBPKMnlZHJVVIWYT04CwCGHhucTY7aY3dr4VlQ/ WQ1rNv1R/fh/EMOarEZ+u8PhGoBcu8ZD9l4rW2SLFT8t0vioQEG1ftCfENsfWP3w5Dys jHGj9lJnfXuwUmI7usU48C9oCjxge1/JMNZp5a31g5Gs9BXnKW1VULOJlwchJNcv6FyS //t7laAEFXQC4VJX/34/i2C7ynWSlPalyazA9RkgjZChDj8gLwbD2odJJHLMGYWpkYUA fKog== 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=G9xC5Fve76Zxfa+i6e3m1Pbe/qNBhFg57+P7PBGpq4g=; b=cI7ptccJ/mxIjLKXpaNVXT+6aP9G+OPVKo/gnJCXUjfEkfyweTQELuSF3lUg7jSF4Y spnKp8AnqPKaFA6jBS8XoMLSDVP8KVjsxjl++/yEmOEtb1ndEJTqHuPWnmQWdZ66FBne w9jVx/S8P/yyxFB3s4Wj27Qguyln35JSiY7CvsXKFQvD9ruXYwvOAMdd3M2ZkmodjWzX Qxca6QzMgDy4tQqI7KfxS6288pVR/KuYI8MMi3muY4AD+5hzlEApJY4FfMl++xTLFOde gRuwamwQeue1M1y+M33BZl+wXdu1a/hIXosRwXCLI1y/54u5fROHRotDcodrIa02xrkP Zgdw== 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 u30si9968875edd.119.2019.11.30.01.37.30; Sat, 30 Nov 2019 01:37:53 -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 S1726946AbfK3Jda (ORCPT + 99 others); Sat, 30 Nov 2019 04:33:30 -0500 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:50427 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbfK3Jda (ORCPT ); Sat, 30 Nov 2019 04:33:30 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R221e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04446;MF=wenyang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0TjSu.65_1575106399; Received: from localhost(mailfrom:wenyang@linux.alibaba.com fp:SMTPD_---0TjSu.65_1575106399) by smtp.aliyun-inc.com(127.0.0.1); Sat, 30 Nov 2019 17:33:26 +0800 From: Wen Yang To: Richard Weinberger , Miquel Raynal , Vignesh Raghavendra Cc: xlpang@linux.alibaba.com, Wen Yang , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] UBI: fix use after free in ubi_remove_volume() Date: Sat, 30 Nov 2019 17:33:17 +0800 Message-Id: <20191130093317.31352-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 "vol" after it has been freed. Fixes: 493cfaeaa0c9 ("mtd: utilize new cdev_device_add helper function") Signed-off-by: Wen Yang Cc: Richard Weinberger Cc: Miquel Raynal Cc: Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/mtd/ubi/vmt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index 139ee13..8ff1478 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c @@ -375,7 +375,6 @@ int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl) } cdev_device_del(&vol->cdev, &vol->dev); - put_device(&vol->dev); spin_lock(&ubi->volumes_lock); ubi->rsvd_pebs -= reserved_pebs; @@ -388,6 +387,8 @@ int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl) if (!no_vtbl) self_check_volumes(ubi); + put_device(&vol->dev); + return 0; out_err: -- 1.8.3.1