Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1239444rdh; Mon, 25 Sep 2023 07:10:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFWZJF8bt7uxoCwlTPW08wCPWX26jqYhKLMs+KAh/w4Knagw7bfG8PPu79x0UEDVNt/7mzc X-Received: by 2002:a05:6358:398f:b0:143:a0bf:9a49 with SMTP id b15-20020a056358398f00b00143a0bf9a49mr7816531rwe.3.1695651053265; Mon, 25 Sep 2023 07:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695651053; cv=none; d=google.com; s=arc-20160816; b=lkn+O9kHppiWrCcBmHiqoesj9R5vMGBWq7YrCMFKopO3BojwOxupmSQISDy7As8B83 mQVNUqxj6O9KKzxjnJGICJqfMrOgM/jH9+nZvoANbIFKXvCK4shQUZeWB5G81ilKAIJG oHJz1r1lY2UVmEKarWf5v/JN/3s4OiqmNKtxZPIWGQX8ZUAbVCRUHrdYvjstrLJl4Uz8 x0RrkOaJfTp0jpm1ZdVM7RZ0w9EKbhxXYFRSZMHmsfSUxf7xvt986e6OUbQiKJ2+VG3A mURLdaW2WCbjdEwKeziIPtVikT4GFDA0XAMnFBjHMS/HztqXQmmmxlO8cRdbi0ZSs4Dn Q0WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date; bh=fjOsPV/qFf36g+AHaX04Zcm4VGFn0s8zIc6bapTEsxE=; fh=E9bvD8sPtxxF2TIb4PdsLMhugG/zLa+vn7QFFlSVVHk=; b=sTeFlQaenw9pDATAABTMzh8taDvzvlOUfuldf1rRjFHov3p+4P+byy3JtdoKnwmz4G iw0EzWsqPMcmYGlMWpR5kCpc3ofQ8bh4XtdyVFRPUUmFGKUGH8jsioBirYoMLRE9IQ6B kNsPB2Eb/b+GJjlv0nDeiD420fAHK3mlqxq0CvZvo6rsYZjijA4gRKtM6nbHFHoon1e7 oyMh3GQ+WBocdU4vW0E9d7DUzffz73kn65wsCISwFu/DzdRzDJWr0lwKkg7w6J1y1o9U 2wTUqkKisQWPsaQJ+YMHOcPI8tJhz9WLWajEyOCvfOfEUXQcWJBucKAXFtfWmXKTpf5g dj2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id z13-20020a6553cd000000b00574166b7d34si9902063pgr.881.2023.09.25.07.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 07:10:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 85498803FC08; Mon, 25 Sep 2023 07:03:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230436AbjIYODS convert rfc822-to-8bit (ORCPT + 99 others); Mon, 25 Sep 2023 10:03:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbjIYODQ (ORCPT ); Mon, 25 Sep 2023 10:03:16 -0400 Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF9A9109 for ; Mon, 25 Sep 2023 07:03:06 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 84C78635DB5B; Mon, 25 Sep 2023 16:03:04 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id IuqLOyVDcGkJ; Mon, 25 Sep 2023 16:03:03 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 932CE622F591; Mon, 25 Sep 2023 16:03:03 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id slzN9QCr4ZQj; Mon, 25 Sep 2023 16:03:03 +0200 (CEST) Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) by lithops.sigma-star.at (Postfix) with ESMTP id 71238635DB5B; Mon, 25 Sep 2023 16:03:03 +0200 (CEST) Date: Mon, 25 Sep 2023 16:03:03 +0200 (CEST) From: Richard Weinberger To: ZhaoLong Wang Cc: Miquel Raynal , Vignesh Raghavendra , linux-mtd , linux-kernel , chengzhihao1 , yi zhang , yangerkun Message-ID: <1131184426.81026.1695650583370.JavaMail.zimbra@nod.at> In-Reply-To: <20230923005856.2538223-1-wangzhaolong1@huawei.com> References: <20230923005856.2538223-1-wangzhaolong1@huawei.com> Subject: Re: [RFC] mtd: Fix error code loss in mtdchar_read() function. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Originating-IP: [195.201.40.130] X-Mailer: Zimbra 8.8.12_GA_3807 (ZimbraWebClient - FF97 (Linux)/8.8.12_GA_3809) Thread-Topic: Fix error code loss in mtdchar_read() function. Thread-Index: K2deZwmqse54Lnhyky63J7p7EYeVMQ== X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 25 Sep 2023 07:03:16 -0700 (PDT) ----- Ursprüngliche Mail ----- > Von: "ZhaoLong Wang" > An: "Miquel Raynal" , "richard" , "Vignesh Raghavendra" > CC: "linux-mtd" , "linux-kernel" , "chengzhihao1" > , "ZhaoLong Wang" , "yi zhang" , "yangerkun" > > Gesendet: Samstag, 23. September 2023 02:58:56 > Betreff: [RFC] mtd: Fix error code loss in mtdchar_read() function. > In the first while loop, if the mtd_read() function returns -EBADMSG > and 'retlen' returns 0, the loop break and the function returns value > 'total_retlen' is 0, not the error code. Given this a second thought. I don't think a NAND driver is allowed to return less than requests bytes and setting EBADMSG. UBI's IO path has a comment on that: /* * The driver should never return -EBADMSG if it failed to read * all the requested data. But some buggy drivers might do * this, so we change it to -EIO. */ if (read != len && mtd_is_eccerr(err)) { ubi_assert(0); err = -EIO; } Thanks, //richard