From patchwork Mon Feb 18 12:30:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 158600 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2434097jaa; Mon, 18 Feb 2019 04:30:27 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib1AXxGCnbX02JUEfay3MXXRrVBpXRof4iQxpinzLQuqmhfVyUnfQaHb+s/ajzHqLlgd/h7 X-Received: by 2002:a62:6f88:: with SMTP id k130mr23848704pfc.234.1550493027624; Mon, 18 Feb 2019 04:30:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550493027; cv=none; d=google.com; s=arc-20160816; b=ZMuYvPQWV9Jm4mbRfRsYypnSGGF+6CSvIZUMEzeD55RzMbyziwVwzEFqjmcImjopFv LXiNxlbFc/bf3zQv09ES2cvydqbnQXCNnHoPGB71lPcbrteCTRIIqnWxpyD5PbgTdlz3 zB92Zk7QDQgeK3zOb1Kw2O9yYwx9/33iNkvPfddEvdov+vlRv9II4GMvYYJymxgzH83F M6JDH0OpjD6eRQZwSc6z35Q/Y+1IfOENCEB7uBUoGO7CRQUnvG6XQ2k8YI43FdGufXMF BzHztdjkL2m88S5gP3vc9zGzwR3eXFz7aV6+AdW/3CPgOohLj6yPY6HuUxARCbUToU1b Gtsg== 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=m3Y3LoSiQ+wxcXbUkffnFSecXDedEAwH7/+X+/mW8vQ=; b=xkNkqKx/S3wZZh6Wl3kgF7uKWW8/raboLN/uIxNVvfCsP2hf2VqAcIJvylTQwyJL46 7HwuTO/iGMSOpMjhrtYGVHKNzwj+wz1CVbmHGAKuQ3R/WvlLKFB26KcmWHBhuEE9dpZr 1wxI/NQG+SF31SgwDE5Qh7xn02LVOlMa6ccbZ8YtZibH3yiZ4qstM9FsaUgHjbdZjYKz /lR6PKulpQCSAdnJ/1qvZI4YbevXxgggVKjMCgyDXqlLun4Ze9D++ocw2Ynao6nO9gLJ /s4J+j0k6azn8ap2V2gp+I0lTarpkS9AvDRiWIf9h/k0ddvReoLNsa0hPdF6iMz3fJys kxgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Rd+96Z/B"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s13si9827354pgp.347.2019.02.18.04.30.27; Mon, 18 Feb 2019 04:30:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b="Rd+96Z/B"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730930AbfBRMa1 (ORCPT + 15 others); Mon, 18 Feb 2019 07:30:27 -0500 Received: from mail-yb1-f194.google.com ([209.85.219.194]:43185 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729690AbfBRMa0 (ORCPT ); Mon, 18 Feb 2019 07:30:26 -0500 Received: by mail-yb1-f194.google.com with SMTP id s76so6667274ybs.10 for ; Mon, 18 Feb 2019 04:30:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m3Y3LoSiQ+wxcXbUkffnFSecXDedEAwH7/+X+/mW8vQ=; b=Rd+96Z/BzxhUuL4DcaHSHPWuKSRmJTVzQ9K1J8hN7Ltg5VXmjn//RfFvtN8IUwpklI Imnwfso19kqNx/Nex1P0184duvBtwLaJr2Fubs3DNmEcu2kzo8+GU7ow1V2m2e2g4nS9 Icg7hWy2IbTeT+mYOLCIQ6qVhAJJ8DQ8hJ/8CXUIMG62K0OQn0mZXhKIbl6qNobhYDg9 wJY7tvskin1ymGghfvh0jNk4S9HzKxAYnpi0hhoGV44QNXCPf3QI90pCb+0ifu3Ac65P V9i+I0NxRPCxvJUr1I9MbbYGPmip5sLN8XB7j0y3X/8H76QVmSiiPgQidyuHl64Hl/gg k6KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m3Y3LoSiQ+wxcXbUkffnFSecXDedEAwH7/+X+/mW8vQ=; b=kUkbC/3ZS7AwZ/YWqG82wulwTrYglH3SzwH0RCb83q8Kw3G4h2sCiDO0MMsEilO/jM BCzoyy6CJRIovtja7SKtwgeZ3oKqhaGH1QxXKCPfrbzjnzjxl4GzqzaqJzeyDEvLvtHo Edt5WJFW2faCufl8yvCPOzkMtglyIGDsp0Xh3mtfisX6Wiav4zbSgUP7xLcIScsEESdV LcFGG3OFCYtde3V9AZVUFhY7oD4h9phIdTAlKoaSP7tEQ8el8ARi5G6e4/gwwxyEq/u1 8EMRSkX6n3kddJp04pK090cvoACcRJN/j0/nUOpzZdaH13yjqOX5afQ4poHLNSz+iob+ ZWNw== X-Gm-Message-State: AHQUAuarD5UANGde2wJyhuOAhwcsciQ8Qcy3IMuxVv9/dM8u/yFgoeAG yGAgJdu1+022+6RK/4/4PTdwhw== X-Received: by 2002:a25:3004:: with SMTP id w4mr18682745ybw.461.1550493025858; Mon, 18 Feb 2019 04:30:25 -0800 (PST) Received: from localhost.localdomain ([106.51.22.126]) by smtp.gmail.com with ESMTPSA id z77sm1663695ywz.91.2019.02.18.04.30.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Feb 2019 04:30:25 -0800 (PST) From: Amit Pundir To: Greg KH Cc: Stable , Linus Walleij , =?utf-8?b?UmFmYcWCIE1pxYJl?= =?utf-8?q?cki?= , Boris Brezillon Subject: [PATCH for-4.14.y+] mtd: keep original flags for every struct mtd_info Date: Mon, 18 Feb 2019 18:00:12 +0530 Message-Id: <1550493012-5959-3-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550493012-5959-1-git-send-email-amit.pundir@linaro.org> References: <1550493012-5959-1-git-send-email-amit.pundir@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Rafał Miłecki commit 1186af457cc186c5ed01708da71b1ffbdf0a2638 upstream. When allocating a new partition mtd subsystem runs internal tests in the allocate_partition(). They may result in modifying specified flags (e.g. dropping some /features/ like write access). Those constraints don't have to be necessary true for subpartitions. It may happen parent partition isn't block aligned (effectively disabling write access) while subpartition may fit blocks nicely. In such case all checks should be run again (starting with original flags value). Signed-off-by: Rafał Miłecki Signed-off-by: Boris Brezillon Signed-off-by: Amit Pundir --- I understand that it doesn't exactly fit into Stable rules but I didn't want to assume anything, so sending it up for review. Cherry-picked from lede tree https://git.lede-project.org/?p=source.git and build tested on v4.14.97 and v4.19.19 for ARCH=arm/arm64 defconfig. drivers/mtd/mtdcore.c | 2 ++ drivers/mtd/mtdpart.c | 3 ++- include/linux/mtd/mtd.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 97ac219c082e..2d24701255e5 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -665,6 +665,8 @@ static void mtd_set_dev_defaults(struct mtd_info *mtd) } else { pr_debug("mtd device won't show a device symlink in sysfs\n"); } + + mtd->orig_flags = mtd->flags; } /** diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 99c460facd5e..2b6e53af47da 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -346,7 +346,8 @@ static struct mtd_part *allocate_partition(struct mtd_info *parent, /* set up the MTD object for this partition */ slave->mtd.type = parent->type; - slave->mtd.flags = parent->flags & ~part->mask_flags; + slave->mtd.flags = parent->orig_flags & ~part->mask_flags; + slave->mtd.orig_flags = slave->mtd.flags; slave->mtd.size = part->size; slave->mtd.writesize = parent->writesize; slave->mtd.writebufsize = parent->writebufsize; diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index cd0be91bdefa..b491a08e87e5 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -207,6 +207,7 @@ struct mtd_debug_info { struct mtd_info { u_char type; uint32_t flags; + uint32_t orig_flags; /* Flags as before running mtd checks */ uint64_t size; // Total size of the MTD /* "Major" erase size for the device. Naïve users may take this