Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp639048imu; Tue, 27 Nov 2018 19:01:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/W9hbXBuzcnU/vuvHWoBIwmMNwUVQBHZyxcHEaqVi67d6LedmIizN5ATQ3EWABSrGZFfAh2 X-Received: by 2002:a17:902:a9:: with SMTP id a38-v6mr35398927pla.7.1543374093560; Tue, 27 Nov 2018 19:01:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543374093; cv=none; d=google.com; s=arc-20160816; b=0K0sI8QFfy3Fr2cuGjNHbombZm0HfEDMvL0Dvs7ov46l9IJoJ3luji80WLW5WMDY7I IrndXYPybzP8ahTJQiQWO5tA5+UNDO/4A3eqzrvj1d/jfkoKTnrDQns3CFdYhAzPhrcl qBH9XNmKcnzO0aFgBtaIOS9YjyL5GByP3JZedjz8fDK9MTDR6aympYSzH2chA2yGgQub 5bSwFaklze/8poBm7h47McR8aXB1cfUJmr99JpaPCGdf91sSOLBOIfMXfb1RucecmNnY RmWCdL6X7gZMEe/MvYm0qtlLGa8y2P7MCG/0fPxmfZNLIEeH46JpbDKWrhO9E1FIxT+r lNKg== 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 :dkim-signature; bh=7i7fL+bCrUD9bBaqpulfNxplHlrxv2m9R5qJgKhqT8A=; b=GmtiELM4cmMiYhwYls4p56Gd9rnyn7SV5++GNCjEk5LX4V120uwb/wzh/MEsZiRMqO QrOpUaLRk4mZMf/mAn7sWD8bbDCC4cQ2MUspIfnQVP/1j/91OL0as1BG0PG25Lff3B03 Dr0lcQnCtMWx7Cl2TPHeVuiSeh0eea17AfAfQEaXSMaCM+e4c1IwWjPkp35gsUxiaPtZ OuAGPo67eU3t6KC9T+yFyAfU0v++UlbiHuYIwOliwCtPVZ57l7nv/t9g1tZDmgfqs/q4 v0CM0B8ozvc0PuXUsaX4t554jG5DtEd1eIgeqI2g01qpJ4L9criGNBxvs4mX4e53rg4P fSNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=LSYeq01U; 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 w11si5555734pgp.161.2018.11.27.19.01.14; Tue, 27 Nov 2018 19:01: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; dkim=pass header.i=@163.com header.s=s110527 header.b=LSYeq01U; 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 S1727025AbeK1N7M (ORCPT + 99 others); Wed, 28 Nov 2018 08:59:12 -0500 Received: from m12-11.163.com ([220.181.12.11]:38361 "EHLO m12-11.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726847AbeK1N7L (ORCPT ); Wed, 28 Nov 2018 08:59:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=7i7fL+bCrUD9bBaqpu lfNxplHlrxv2m9R5qJgKhqT8A=; b=LSYeq01U9K1mvTHpcXsulJmcqSuYzOzaMO I4VZ9rLsx9tMCbubcYwMs9ciXuyU8TVAj1HAD9YucqG6lPaDeAqgN683EUKsPndU 2++I50UOPDTVDe3s3TukiQuhnSX1JBsuvMdbiXM88M4BkmW1tfGgnH3LwcUkozrh ezKlq2Le0= Received: from bp.localdomain (unknown [106.120.213.96]) by smtp7 (Coremail) with SMTP id C8CowACHu5EcBP5bJbArCQ--.2592S3; Wed, 28 Nov 2018 10:57:34 +0800 (CST) From: Pan Bian To: Artem Bityutskiy , Richard Weinberger , David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH] ubi: put MTD device after it is not used Date: Wed, 28 Nov 2018 10:57:33 +0800 Message-Id: <1543373853-80379-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: C8CowACHu5EcBP5bJbArCQ--.2592S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrtF4xAr43GFW8XrWrGw1ftFb_yoWfGFgEgr 9rWr4qqF4vgFn7K3WYyr15ZrW8t3WYq3yIkF1Sq393ArZ8ZF4DX34kWr1fGanruw47AF95 JFWj9w4rGr47XjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0C_MDUUUUU== X-Originating-IP: [106.120.213.96] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/xtbBZx4NcletsJ3UaQAAss Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The MTD device reference is dropped via put_mtd_device, however its field ->index is read and passed to ubi_msg. To fix this, the patch moves the reference dropping after calling ubi_msg. Signed-off-by: Pan Bian --- drivers/mtd/ubi/build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index a4e3454..09170b7 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -1101,10 +1101,10 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway) ubi_wl_close(ubi); ubi_free_internal_volumes(ubi); vfree(ubi->vtbl); - put_mtd_device(ubi->mtd); vfree(ubi->peb_buf); vfree(ubi->fm_buf); ubi_msg(ubi, "mtd%d is detached", ubi->mtd->index); + put_mtd_device(ubi->mtd); put_device(&ubi->dev); return 0; } -- 2.7.4