Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4561357pja; Thu, 21 Nov 2019 21:54:11 -0800 (PST) X-Google-Smtp-Source: APXvYqzfcbBjpDg7Q+97TL0dAgQpGj6RM9dGPKXDFwPqMoKlSvY6bJLQPQWgIiHV8H5XGljRkmUZ X-Received: by 2002:a17:906:aad5:: with SMTP id kt21mr19373643ejb.228.1574402051362; Thu, 21 Nov 2019 21:54:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574402051; cv=none; d=google.com; s=arc-20160816; b=SIbkuKIZbhFXLY+SLvnrVSEy0Z6goLtkrR2ZjzAq8hBRvlzmOaY4Eqwq9V16NEC3k/ 7XVTYKzzo8zufhdK5WiF/hD7/5F+6i3ykqiaZ2NSkVtBQAVxhwrgjM48JSU1fpWQ9DUm vjVZZxgPNGg/kgo2q5qWETIVfciaqtu8HQrdJJahUr10iidUPJrapOO2dtAmf5mcS5Mg GClKBI9TgF1mbidfkPGb4CEue0n0iGgvGLtJFsQ0kiqjC+eDWIg+D94CDtGZ8ZF5ltPb dILIyc4wFH5Z1JOiGHjViPyy7n3wA2WVKshodPK4ZCqAnWXsz9D3gAn3XAemKpCG3/p4 QKrA== 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:date:subject:cc:to:from :dkim-signature; bh=dVJ0JZuBtkULCrBIQHmniHcj3TXSzYLK7VTpcFBIKEg=; b=LfE4zY0Ozpj6v63rTZTRsRiyp1qEozyIhxMWrpiMem5vDf59DvrxRPfBp1af/xWz7G n6C+nQoYUSnIC/AG1p+9yXvHNIFLPWJTo6F/rVqrIzxDcEVKyY6Sz1XMReGDJJChHEhq bjzAyN9n1S3CAf0hOWQBRdDFaLLO8Ffmu+VJOfQyaBFGM05gLBnXa5IXA4jBAk5LzZJE ml48sTTJ912PMpNkPWLxyg7io4zC+8q5hcU8VIREYGhqjDMdP5g/uI8s6lBAzn7DtfrB 8xNd2bfv+WB2aJSBFewidXluwgnI/yDEtI+rlLw4esHgH+EWjnk4MpxdQTctAcaR+oBP CfCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="eWktz9/D"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f22si4117315eds.54.2019.11.21.21.53.46; Thu, 21 Nov 2019 21:54:11 -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=@kernel.org header.s=default header.b="eWktz9/D"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727556AbfKVFuN (ORCPT + 99 others); Fri, 22 Nov 2019 00:50:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:54596 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727530AbfKVFuK (ORCPT ); Fri, 22 Nov 2019 00:50:10 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 28F5E2071F; Fri, 22 Nov 2019 05:50:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401809; bh=NIBG/DzQYeupRi6YDd/Ko+G1upVp5K5Gk4rxGAwR4UQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eWktz9/DNvouk9H42TfUHimTFYe7mPscaBIKN28Vd2mS0UXVe2ayKyelDWBS76ggu 1qng3dLFy3N/w4kWz9gJgLGAQM4xL8RujQeNb8xwl16NIQrmFD4mIXGqpG4TO7viTk /S3Om8fheGBFhgLOQIQAQaBKtv4a0jHgjeRkzvt8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pan Bian , Boris Brezillon , Richard Weinberger , Sasha Levin , linux-mtd@lists.infradead.org Subject: [PATCH AUTOSEL 4.19 054/219] ubi: Put MTD device after it is not used Date: Fri, 22 Nov 2019 00:46:26 -0500 Message-Id: <20191122054911.1750-47-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pan Bian [ Upstream commit b95f83ab762dd6211351b9140f99f43644076ca8 ] 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 Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- 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 d2a726654ff11..c120c8761fcd2 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.20.1