Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp851232imu; Wed, 28 Nov 2018 00:06:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/XTBZbw+eebYZBMTIswHLfYD4a8iT3t0vzwoKzVDguf3ZQlJgucs/dVEqAgMyFfLyp3kHgu X-Received: by 2002:a17:902:8541:: with SMTP id d1mr11900080plo.205.1543392401113; Wed, 28 Nov 2018 00:06:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543392401; cv=none; d=google.com; s=arc-20160816; b=URjM/O7BExVAh3vYDpMQJIX9ZQPTDSC5vG49+8OGi8jM9Zo6C3oBigf7CI71PWRi6u bxlPmMzoBV0c3ME5VB1ht/JDnO8lFD/2dgboGzIFd0N9o2Xl5oCae0w7djRlbjZygtDi 1IaaWsg+ubBDcZZHf5mA52NUlVIp+LapEQ3YNr4pWIbzW3XAq4/o663JQvXWLcT8GtHM kJVoiY0mgJ6G5KIf2+g/XH6GZH632tKml980oaEGgIbBXWVeiQSfjF7wE5M3LL4CYj0s jLnRMKed8y3BrAWrlkBohnkTJDQSLYi1cK1/5iBLztw0Na2kg9m9APv6n9n4xsFisrho qqeQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=KSlBcfdl3N69qz+wNT0FWZo3jT3p/ZvOg3acr8m6RPI=; b=quxW5/DvewWoZnDO0NFMAknGvC1rTz+wDUJxS2VkxqKqK9fBaI+s2BYu7uqKtdiLxH Y4co4ys2IDj2ZAtOq1lEZRSOi0uuZptkWoRiBDHEplJECYCPgp16J2c2+MWw6BD4tg+e Pth4LrxCKBkubw/vHLxYrsMcRK7gT325KiCZRxxAIV9f95Ymd2v/z7BqBVRE42p+LTqw g2pg5SqtEwkOXEfpBmsP5gzwA4ZwFGpKQxi9iUfhZr2NXKK1dRehS/FQgCNTAs/7JsE7 chNEAx6WpN+VmTav8/u9Vpym4cubkp9QJI2dt5vAZdTzP/2TLfblSsclu/5u6YewqotR g3bA== 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 l4-v6si7025498plb.258.2018.11.28.00.06.25; Wed, 28 Nov 2018 00:06:41 -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 S1727668AbeK1TGN (ORCPT + 99 others); Wed, 28 Nov 2018 14:06:13 -0500 Received: from mail.bootlin.com ([62.4.15.54]:40152 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727268AbeK1TGN (ORCPT ); Wed, 28 Nov 2018 14:06:13 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id E775320731; Wed, 28 Nov 2018 09:05:26 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from bbrezillon (aaubervilliers-681-1-94-205.w90-88.abo.wanadoo.fr [90.88.35.205]) by mail.bootlin.com (Postfix) with ESMTPSA id A93CC206D8; Wed, 28 Nov 2018 09:05:16 +0100 (CET) Date: Wed, 28 Nov 2018 09:05:16 +0100 From: Boris Brezillon To: Pan Bian Cc: Artem Bityutskiy , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ubi: put MTD device after it is not used Message-ID: <20181128090516.16e89c94@bbrezillon> In-Reply-To: <1543373853-80379-1-git-send-email-bianpan2016@163.com> References: <1543373853-80379-1-git-send-email-bianpan2016@163.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 28 Nov 2018 10:57:33 +0800 Pan Bian wrote: > 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 Reviewed-by: Boris Brezillon > --- > 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); Maybe we should move some of these to the dev->release() or class->dev_release() hook. > put_device(&ubi->dev); > return 0; > }