Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1270693iob; Wed, 4 May 2022 19:26:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6lqDgpeCEFXq15unGtLoAmfeWxEhqRNGFiqZJ4o/50cy9csMOy8r3f9fb5hwz3BrxLs3z X-Received: by 2002:a17:90b:3909:b0:1dc:2805:9aeb with SMTP id ob9-20020a17090b390900b001dc28059aebmr3225804pjb.147.1651717570162; Wed, 04 May 2022 19:26:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651717570; cv=none; d=google.com; s=arc-20160816; b=kVGj6V3PqeMtjm09Vxm0jR9Sd5w+cEneqVwwjhue4brkShsTbyWKb5D2XFAQ/NbAy0 C9OIRWWjMysbh2qVoUWE1529uRSjDUxLUBdlj5jfCtkh6VJpgNmOS/Nnq8CBLgengg2d 4a6wY18wA+QaqkbZUv+ZKQRVGbVJzAzlyUJAjA+mgsBcWJcNiYu4yVx6druhcV2ullFw hsv+c9EAdYu0qClC0qlekE79zrc5nvgR/cPgmFA1v4T9mQAsMEs0W/F2wX97hpk10vEd jn1bIPiymjviEDIRdtXOYbwlgj2vPfVd+HMoIxdiYZ/NopPF+CmYnjRcUJhJflwg4C07 ovpw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EdAdCtIuJny9MgJiH9YoDaUmpvKsfUwlslY1M6YXrzA=; b=XmEatMTCg1acjCznJzMtORa+fJejM/O1Z5486j+OnjKvs39AldLwhkb1as9I+5adZX q6s5w0BdFsDjRL3hFuajZXBb7Y+zOzJitc95n9P8i9dyq2cBifbS4fhCYEEYAdi06n+A UFjYkdza2+RLtWEnRDRlghypn4Wh14wBJ+YZyx0SM8jp22JnlZzhmgN+Xq2neoYppjHN qB+K1GVMad+JjTVq54gcD+c7RZRchZHoBKgpd9l6QfsB6fjYCXrI3XdIn348FC6ZZuYM 5Gmo9ixJQW3Bs+93KMpGMTvxmM2DJMmFcUsVo2grQa3HfUlQu/lB1JgdtrKsC8BpeHiQ kRdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AXQAiLyx; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x16-20020a170902ec9000b00156eeb5cd6bsi453865plg.562.2022.05.04.19.25.53; Wed, 04 May 2022 19:26:10 -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=@linuxfoundation.org header.s=korg header.b=AXQAiLyx; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352272AbiEDRRm (ORCPT + 99 others); Wed, 4 May 2022 13:17:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356073AbiEDREw (ORCPT ); Wed, 4 May 2022 13:04:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B16DF50443; Wed, 4 May 2022 09:53:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3D5A461505; Wed, 4 May 2022 16:53:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 832F5C385AF; Wed, 4 May 2022 16:53:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683224; bh=9aKAC8bS8AJ3whFajoPKnF48+NJXL61N8ubLWROvCB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AXQAiLyxgnnqP4hw+6yurCBMlIK5zCk50T86KI6xc7PLZ1ZiCFxg9i7rzy5jgy7QA hMME7zrfAoyoODPsvGOho4bdcEEZUaeED+wHg+gJt9DH28I82XLHjqrPWkLSxcUQkp nY77Zhq7hQfqxgaEqYFTjQonVd/YwJdNt24leEx8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oleksandr Ocheretnyi , Miquel Raynal , Sasha Levin Subject: [PATCH 5.15 077/177] mtd: fix part field data corruption in mtd_info Date: Wed, 4 May 2022 18:44:30 +0200 Message-Id: <20220504153059.970955149@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Oleksandr Ocheretnyi [ Upstream commit 37c5f9e80e015d0df17d0c377c18523002986851 ] 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 Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20220417184649.449289-1-oocheret@cisco.com Signed-off-by: Sasha Levin --- 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.35.1