Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp567418rwb; Wed, 9 Nov 2022 06:14:31 -0800 (PST) X-Google-Smtp-Source: AMsMyM7RLGlqRpqZXOi6LRqFnO2nCX/Zl2r4ZismIZGpZKmKP7ZAOwclETc5UuwaCxehMu3ILln7 X-Received: by 2002:a17:906:fe44:b0:77c:e313:a8e8 with SMTP id wz4-20020a170906fe4400b0077ce313a8e8mr58542089ejb.700.1668003271375; Wed, 09 Nov 2022 06:14:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003271; cv=none; d=google.com; s=arc-20160816; b=0jVAGiwD229kZaUT0Vv95NYHxWP+jxTsn6gACgIjebxS3QPeXLh+biqtwwCp6vnFKk GuITCZZ/RTdgscXqcs6iGq2Qow7i8fGBqJG1hGdZQ5JAhrZC5S0CpR65VpwR0QuAaNNL Pj/cGGTb8FkZvc1XSZahQMYMQS6pUqhqKRkPFHIUDo8McHUPTf48/1LtP7TbeShCTddP Nr02WHq6tCRm5d+Q/XTBT0qBrWRnD6ZZtm0/9vkUrW+sSdtrxsXJpP79fYJr6ZYjIaXl k0/VMIop5OAzGYPzKrIM3ys3S7k3AgeXDejxS38ocHIYznR5nJcxbok+R8al8QtTG049 bBig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4VpRHLspr5DIHc7t4t1HYUCiM3aAiSiNI2OEfUU8cU4=; b=gUHHaE8Ra4JbPJ+iijj+rQZcTdmd4usDRsAUnlKfEUUSHpvssU/wDfj0qo87+9bn3a d/i5zmGZ1ljW1qeoL/W7LbF/yqdkTFhF92uGcHoeRiQgwRlnP8f19/tHEXaMId8KIOjy GzLDRotMVAcBtwAFuC8qnGAA5MhMhYrEbxdrhWI+1O0578jNRTdKdS6jIbbxpI3CdVjN ubGmpztmioL6UbstmlU8krkMW5tQFUuItIOZw8VgpaChIB+ejq+T9SxK2A40Tj1ABj9S RtMAov4+G8wsazuC77vlr9LSpk4hxnWIcBAYxlmIT26w07UdFnDU/pwna/isw6Fz+1fH aySQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=pCUS5y6P; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r9-20020a05640251c900b0045c97ee2b01si17926820edd.616.2022.11.09.06.14.07; Wed, 09 Nov 2022 06:14:31 -0800 (PST) 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=@infradead.org header.s=casper.20170209 header.b=pCUS5y6P; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229953AbiKIN67 (ORCPT + 92 others); Wed, 9 Nov 2022 08:58:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230165AbiKIN6y (ORCPT ); Wed, 9 Nov 2022 08:58:54 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07B21E75; Wed, 9 Nov 2022 05:58:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=4VpRHLspr5DIHc7t4t1HYUCiM3aAiSiNI2OEfUU8cU4=; b=pCUS5y6P7N1AyeFOOeR6NkwUBM o7SFa1YK/Ev7FSLtVhVBmdQxGv553RSadfJIkfJ768FKs/KKeqtIspPSo9SOHi/78zGMTPgWd46h+ XCkdozXIeQzXhqA18C7ZUrlxMHqEA7huMsm6GQbyNrSloJCnLm54X9+F37Sqo9qiUxXMPeE30e8w3 2YzLhBTf4x2LkKUqxVjlLxnGW79Av6bIpO0+XB/zHAp2qbmP5KYHkwuu5Zo99ZBfh78coLR/FP8fG 7Lje7P7Fsutf5ELtj7q5oXUS4b2IV9PlmZ+JcnyzlB8BDij/0UaD1MuHPvntDLA8lSoal/Xe1POpM il7/hZYQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oslb3-00BEj0-Ll; Wed, 09 Nov 2022 13:58:29 +0000 Date: Wed, 9 Nov 2022 13:58:29 +0000 From: Matthew Wilcox To: Daniel Golle Cc: Jens Axboe , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Davidlohr Bueso , "Martin K. Petersen" , Chaitanya Kulkarni , Ming Lei , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-efi@vger.kernel.org Subject: Re: [PATCH v4 2/5] block: add partition parser for U-Boot uImage.FIT Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,PDS_OTHER_BAD_TLD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE 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 On Tue, Nov 08, 2022 at 11:03:16PM +0000, Daniel Golle wrote: > + /* map first page */ > + page = read_mapping_page( > + mapping, fit_start_sector >> (PAGE_SHIFT - SECTOR_SHIFT), NULL); > + > + if (IS_ERR(page)) > + return -EFAULT; > + > + if (PageError(page)) > + return -EFAULT; Why are you checking for PageError? You won't ever get a page with an error back from read_mapping_page(). And you have the real error in 'page', so why return -EFAUlT, which would indicate a problem copying from the user. Also, this is a great place to use the new folio APIs instead of the old page APIs. So: folio = read_mapping_folio(mapping, fit_start_sector >> PAGE_SECTORS_SHIFT, NULL); if (IS_ERR(folio)) return PTR_ERR(folio); > + init_fit = page_address(page); init_fit = folio_address(folio) + offset_in_folio(folio, fit_start_sector * SECTOR_SIZE); > + if (!init_fit) { > + put_page(page); > + return -EFAULT; > + } page_address() or folio_address() can't ever return NULL, you should just drop this nonsense check. ... actually, why can't you call read_part_sector() and avoid all of this?