Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2354495pxb; Mon, 20 Sep 2021 19:54:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyh306UueFUmOzebedpEEnwxEfOjLDY+eYlwErBAWT2Y4OGNtzFQucy1Ueyma+179FuO91A X-Received: by 2002:a17:906:f0d4:: with SMTP id dk20mr32788436ejb.199.1632192843429; Mon, 20 Sep 2021 19:54:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192843; cv=none; d=google.com; s=arc-20160816; b=PvkkVex9qbDGbocbuxhRuaTAR+jjxEX3gK9suu7Yk9kL8OniHAM/ZAB8yzsmQE0b/j FSFpAkqvGYtxA1pR0RQxiZu5qp2BGUeOXAtaFX4hSF4yLuhUB86speQnXLLegPouCqkW 1+CCoVUzfURmIzdkzuSP5maiHIWMxeOUZplN+vnuj/EJLguNVat2SvNUHKj7gwK0lo61 k+JcbyFYMWqo8K/xF43SP1LcU65qC2p74hU+oJB3qeftw5gsXeR4++2zyPDrzErRe5l+ ekiNA3P7YHvykoT4b9b22gtcUhwCD7zbbIoss+OdIKvfraGpa8h432VMK1WugdOY97QC pK3A== 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=LboSEFXizK8AMlyDuodx5hWcDxkKgYzmdDUV3oSCK+Q=; b=pIvtKMQZR4SigyvtAS9ixKT3q/euws55qWHZPSDLEj3ijMnxAo7pblEfA2O/iabOG4 eITYihRHXbiIApgwieJyUzzUvNJKwW/71Iu0OrJAcMxK7B5/UBE/igc2PdG4sZ/Q1C6l EGUQO9+k1iFE1DxWkYJf6RLP19HJIOYmyVvqQ2wspiGyZ1RaWoUp2AwC9sebM0wmNmxS Fhi7Ce5c/qaQzGSuPI0nkCPh0CIySFhEvPKFMJ6a1X7nfDb4J1Jud2U2lBxyYAMqA+pA 4gvK2ippwixsKKhXMz9Qc4kfBYZP5hlDKbu7uXr/gAS/3HMPa2wPh3jGlXcxiuDMmzdj 5gsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iv6cjLnA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si18462866edj.623.2021.09.20.19.53.40; Mon, 20 Sep 2021 19:54:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iv6cjLnA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231145AbhITS4i (ORCPT + 99 others); Mon, 20 Sep 2021 14:56:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:33188 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385437AbhITSu0 (ORCPT ); Mon, 20 Sep 2021 14:50:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 842646337E; Mon, 20 Sep 2021 17:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632159281; bh=HzC4FEJyEmQTpbQRKNOD5mi7b2ZooCXj66Madr1v6Og=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iv6cjLnAzSml/bhAbTRnuYEb3pnbPvm1PG00MIy59Fo8XDVX7sOkklv8VPLR2W4ax w8pkuHFE2R/QY/xb3b7Rvdrv9w/2E3wRoguRE3JCwtyKyf9MLlqExvStp29u1HpPQP CoMvO6kFnpGYw1bTMKuAkBMZlhmoR5Xf+jj5xZYc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhihao Cheng , Miquel Raynal , Sasha Levin Subject: [PATCH 5.14 132/168] mtd: mtdconcat: Check _read, _write callbacks existence before assignment Date: Mon, 20 Sep 2021 18:44:30 +0200 Message-Id: <20210920163926.005202402@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163921.633181900@linuxfoundation.org> References: <20210920163921.633181900@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhihao Cheng [ Upstream commit a89d69a44e282be95ae76125dddc79515541efeb ] Since 2431c4f5b46c3 ("mtd: Implement mtd_{read,write}() as wrappers around mtd_{read,write}_oob()") don't allow _write|_read and _write_oob|_read_oob existing at the same time, we should check the existence of callbacks "_read and _write" from subdev's master device (We can trust master device since it has been registered) before assigning, otherwise following warning occurs while making concatenated device: WARNING: CPU: 2 PID: 6728 at drivers/mtd/mtdcore.c:595 add_mtd_device+0x7f/0x7b0 Fixes: 2431c4f5b46c3 ("mtd: Implement mtd_{read,write}() around ...") Signed-off-by: Zhihao Cheng Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20210817114857.2784825-3-chengzhihao1@huawei.com Signed-off-by: Sasha Levin --- drivers/mtd/mtdconcat.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index af51eee6b5e8..f685a581df48 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c @@ -694,6 +694,10 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c concat->mtd._block_markbad = concat_block_markbad; if (subdev_master->_panic_write) concat->mtd._panic_write = concat_panic_write; + if (subdev_master->_read) + concat->mtd._read = concat_read; + if (subdev_master->_write) + concat->mtd._write = concat_write; concat->mtd.ecc_stats.badblocks = subdev[0]->ecc_stats.badblocks; @@ -755,8 +759,6 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c concat->mtd.name = name; concat->mtd._erase = concat_erase; - concat->mtd._read = concat_read; - concat->mtd._write = concat_write; concat->mtd._sync = concat_sync; concat->mtd._lock = concat_lock; concat->mtd._unlock = concat_unlock; -- 2.30.2