From patchwork Tue Oct 25 10:52:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li zeming X-Patchwork-Id: 10715 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp937718wru; Tue, 25 Oct 2022 04:04:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4kvbaAdR80Ti3Nvq8QZ/Smdv4DrX/WXhsav4MHTJfAwtwdA9B8E9LQBosfNeQOV/UbkvRh X-Received: by 2002:a05:6402:10c2:b0:45c:3c87:721f with SMTP id p2-20020a05640210c200b0045c3c87721fmr36497456edu.251.1666695880852; Tue, 25 Oct 2022 04:04:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666695880; cv=none; d=google.com; s=arc-20160816; b=RuZ+q6tVLlwTi4cy2jJhFTZKq7vyfIOuS80xEhtbrS0q5tiyP5aAyhmpgmdPXlqMF0 lwHuYV2epY/WVMhjpuA0jNY6MI358DclrwKzSeDp4u/N6CN1tRkm/5QGP1Oijs3maDVd 1uYTd+3ylLFNjgKIPRkc+gcOCFj3vfuiVVCwFMfLG6BY7P4VHA0LrYEAz1+MuVvN5cgi qsrhK/tZsv8r4RnrRPXRFkeZfFy2zc5bLZP0tHNjxFEq3mvuy/oWAnIBeOlDc1zdzozo 5upCeolE9YfuEgsz0lNc7t3s6coVoKBktOi0Z5D22b8jzeqqm5h+sD/VLl5v4HUTzgcW QMYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=V291gI7JfT//eHU/ZSzM+agnUSVWanp+OhMUetsip5I=; b=ZePvQsjsG8hqZFNzUpbZcnK3bYUZ3YB77DdE5EjrYSUQCa3IccKTtl07HuWrlqhNDf yet2DjXwPjwmBhph1bBpqHuwD55ui1hDepIZULmMps8w1I5ARMabduJE+FwDUEOf/xt8 YHNMFOdG0d0TfqlcuRgDGXep3i8bTqtsXgh61uOCEoQwfB6fXdoVEhSEk+zzJVHslou+ z8+BWI9wVuLDDgU8UQQrE6fk/gihzpkk8lv8MmO24kw6PwLn8cM8ZfZEZDw9ofkGZVtv iBiYnhbVJ/xYyoIj9EpN37OTJlOrlsulqQNp0rtHvkkOBr7Vm67oNkC4s+RwsJspR8l1 1EaQ== ARC-Authentication-Results: i=1; mx.google.com; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h4-20020aa7c604000000b004593895fb89si2337596edq.390.2022.10.25.04.04.17; Tue, 25 Oct 2022 04:04:40 -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; 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 S232211AbiJYKxD (ORCPT + 99 others); Tue, 25 Oct 2022 06:53:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232424AbiJYKxA (ORCPT ); Tue, 25 Oct 2022 06:53:00 -0400 Received: from mail.nfschina.com (unknown [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5E7008E790; Tue, 25 Oct 2022 03:52:59 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 22C051E80C8E; Tue, 25 Oct 2022 18:51:37 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7u1RwzFhtnfz; Tue, 25 Oct 2022 18:51:34 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: zeming@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 43DE61E80C82; Tue, 25 Oct 2022 18:51:34 +0800 (CST) From: Li zeming To: quwenruo.btrfs@gmx.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Li zeming Subject: [PATCH v2] btrfs: volumes: Increase bioc pointer check Date: Tue, 25 Oct 2022 18:52:44 +0800 Message-Id: <20221025105244.5212-1-zeming@nfschina.com> X-Mailer: git-send-email 2.18.2 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747649230174388512?= X-GMAIL-MSGID: =?utf-8?q?1747657300219909087?= This patch has the following changes: 1. Modify "is returned" in the comments to "should be returned". 2. Remove the __GFP_NOFAIL flag from the kzalloc function, which returns NULL if kzalloc fails to allocate memory for bioc. Reviewed-by: Qu Wenruo Signed-off-by: Li zeming --- v2: Add annotation vocabulary modify, remove __GFP_NOFAIL flag. fs/btrfs/volumes.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 064ab2a79c80..b8d901f58995 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -5891,7 +5891,9 @@ static struct btrfs_io_context *alloc_btrfs_io_context(struct btrfs_fs_info *fs_ * and the stripes. */ sizeof(u64) * (total_stripes), - GFP_NOFS|__GFP_NOFAIL); + GFP_NOFS); + if (!bioc) + return NULL; atomic_set(&bioc->error, 0); refcount_set(&bioc->refs, 1); @@ -6071,7 +6073,7 @@ struct btrfs_discard_stripe *btrfs_map_discard(struct btrfs_fs_info *fs_info, * array of stripes. * For READ, it also needs to be supported using the same mirror number. * - * If the requested block is not left of the left cursor, EIO is returned. This + * If the requested block is not left of the left cursor, EIO should be returned. This * can happen because btrfs_num_copies() returns one more in the dev-replace * case. */