Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2645057pxb; Mon, 18 Apr 2022 05:28:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxB/AVUClSEe6h0bNkQTEDcJB2QWCwaeI8dj0fzk+f6fGYtScyvOXulRXUmQ2E9g7lRt2Mg X-Received: by 2002:a17:907:96a1:b0:6e8:9dce:c3bc with SMTP id hd33-20020a17090796a100b006e89dcec3bcmr8746074ejc.589.1650284889971; Mon, 18 Apr 2022 05:28:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650284889; cv=none; d=google.com; s=arc-20160816; b=gfnD6U9fg7Sqxie6lXjVI+uxNl+gepKTTV1HKl5jpGOitsXoebR1wYBWLF6gQ8RCnE IciFLKezcpkPZ0MGGzAdoU8akmqXKaQvrGIt0xqza4hHKoC7yh4MKjXQGLxf7KTQ35u6 NqzRDNm2Qb70lCrJQZGeAGQCB5dfZ0NlzgpU83RkxbOjxHM+l+9BgqbKo2zmXNIk1cfk aDKNJCzG/Se1Tf60WGSajSxvI5H5Bl1lVf2dNAUwfDmRcJXAzh4YTRZAPHTNQQKDvbAA YOQMd5f1hOO9pOPicBDBWsDUPGf5m5qp3WtiEapa2zmw10yCOUYa1H5T2zj/VIqp+TTv 3tNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=RhkCC3Yk8PMfEAxeCF/dBBRdEnmVvCXPP2ySqKTbDnE=; b=0xIUCM3egPJCEzO1eWwjuGFxhou/UvDOCajUkpFLCAeeINvC3Oki8daDZwYv+E4quw cDlBw+oi31E5KLMpwp38cuV8GpmQ74z+vR8z4W/ajRLhenR32L+YYb/EFjmLF9fbXdxa DHIUakeh2/+48zldul6xtt8XMbAMd9wv60dx2hedOp6ovmqBqbo3r3Sc6KulHTk/3+YW 5CgefrHcb2Gc7rZm7+p8FxAjnVMmXJH5vqcNPhe3YY9un2PAelNNLO+CCgwt0pdcJZpm 166sSA95yY9UAhXdFkXP3t0vQOcrwD/HZy/LYyh2oqByX053FlR5r7N1v5+5J5uy1eOk HENg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=eoTYQrpW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=cisco.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bq24-20020a170906d0d800b006e88d626e23si5936226ejb.897.2022.04.18.05.27.46; Mon, 18 Apr 2022 05:28:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=eoTYQrpW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=cisco.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234821AbiDQSu3 (ORCPT + 99 others); Sun, 17 Apr 2022 14:50:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233151AbiDQSu2 (ORCPT ); Sun, 17 Apr 2022 14:50:28 -0400 X-Greylist: delayed 62 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 17 Apr 2022 11:47:52 PDT Received: from alln-iport-7.cisco.com (alln-iport-7.cisco.com [173.37.142.94]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A29362DD50 for ; Sun, 17 Apr 2022 11:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1240; q=dns/txt; s=iport; t=1650221272; x=1651430872; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=+BCSFgpwz16cUwJFvXpZTH9edfgHzKDaLBpIEMjSMEU=; b=eoTYQrpWmM5zmhycbomNSN219faboxZVDV6sjNLlh0V480O2ZgJe7idB 9DVwILjZGpzYMT5QfmHeKyAPrK6vWWwRCJm5UOl1seJt0gfPKHKTI/Slb bvB6e4XXdNOhkPdbdLAzkMkOMj3pPE/Tw7XNyZLCXeS23M5UkWnxyCM7e A=; X-IronPort-AV: E=Sophos;i="5.90,267,1643673600"; d="scan'208";a="841891360" Received: from alln-core-2.cisco.com ([173.36.13.135]) by alln-iport-7.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 17 Apr 2022 18:46:50 +0000 Received: from sjc-ads-3421.cisco.com (sjc-ads-3421.cisco.com [171.68.249.119]) by alln-core-2.cisco.com (8.15.2/8.15.2) with ESMTP id 23HIkn0t008765; Sun, 17 Apr 2022 18:46:49 GMT From: Oleksandr Ocheretnyi To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Cc: oocheret@cisco.com Subject: [PATCH] mtd: fix 'part' field data corruption in mtd_info Date: Sun, 17 Apr 2022 11:46:47 -0700 Message-Id: <20220417184649.449289-1-oocheret@cisco.com> X-Mailer: git-send-email 2.26.2.Cisco MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Outbound-SMTP-Client: 171.68.249.119, sjc-ads-3421.cisco.com X-Outbound-Node: alln-core-2.cisco.com X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 46b5889cc2c5 ("mtd: implement proper partition handling") started using "mtd_get_master_ofs()" in mtd callbacks to determine memory offsets by means of 'part' field from mtd_info, what previously was smashed accessing 'master' field in the mtd_set_dev_defaults() method. That provides wrong offset what causes hardware access errors. Just make 'part', 'master' as separate fields, rather than using union type to avoid 'part' data corruption when mtd_set_dev_defaults() is called. Fixes: 46b5889cc2c5 ("mtd: implement proper partition handling") Signed-off-by: Oleksandr Ocheretnyi --- include/linux/mtd/mtd.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 88227044fc86..8a2c60235ebb 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -394,10 +394,8 @@ struct mtd_info { /* List of partitions attached to this MTD device */ struct list_head partitions; - union { - struct mtd_part part; - struct mtd_master master; - }; + struct mtd_part part; + struct mtd_master master; }; static inline struct mtd_info *mtd_get_master(struct mtd_info *mtd) -- 2.26.2.Cisco