From patchwork Tue Oct 25 08:28:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li zeming X-Patchwork-Id: 10595 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp886985wru; Tue, 25 Oct 2022 01:56:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6cP801L/6N/Ll4fJvNoG5HmrOWn0AUSlG1TlgpQli8SA6Mct2nc9niYmfUMrP8l7F02GoG X-Received: by 2002:a17:903:2450:b0:185:4165:be54 with SMTP id l16-20020a170903245000b001854165be54mr37787544pls.104.1666688185178; Tue, 25 Oct 2022 01:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666688185; cv=none; d=google.com; s=arc-20160816; b=PoFsYGRPK8ULYdp+xS404golO4Yebl6CMMIeeRUmeRwYlzLXv66tnMTTe1E8HDolEk O6NPlF7q4j3e/JFVI3C2LXZK9tWkWJh9EvCZa7emks83/Cj2EZLQIbC04qvXZ7VbrnlT 5pohmBxLsRLfLiJfjUtGD2TSqz4kfYqXc1InvUoOlcmWjjzy0bzPWEJ23FZn/DqrWWpi 2Mc8P5+ND9f6lVDuCH9HtAqebmO5n7XeC6Nm+V0HO5cIdIrbZ5XxjrePcZBxqifWCn49 D3Ab0l3FVJPdePF/6KpoAVVbaHcZ9X1/Uf9M3rRbKTpM+2FhIlgL2wRSZ6D2YeVkRiM8 rVwg== 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=y67YZPae/MMAdDbSEoySCBhLfdwjFar8ncOEUvBtCTA=; b=sZA1fgVyIacFu/0OoEgjO4FN2k0Ht4nE4rzNb6x4x8SWKIY5JEf4v5o8pUSfbLXcqb vfXMWXcefL76WxjRLKVPY6mOxfTku/QHnFSjI55Uc9vsVsmx/miUPJ7IykpAfVH6BePO O5xnwzbBJZWmpgKQFKVS/+OlaBInl1jBubJEC1vUuAFZEfVoQDOAw8taI/DVqiJzKrE3 uvj4piBWFO3eHHddfrWz64xpz8omDuk7vURJj5S9F7ompDevKptoDKmt6UH2mcELR3TN iIQAtvbtYeu8cNpZ/ZOE4roK/BdEeKoqed7Rb9ckLYzLa/BIX0MfkpWqIRk49p3uMl9+ wdlQ== 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 h11-20020a170902f2cb00b0017f9b980fadsi1770005plc.446.2022.10.25.01.56.11; Tue, 25 Oct 2022 01:56:25 -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 S232255AbiJYI2o (ORCPT + 99 others); Tue, 25 Oct 2022 04:28:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232199AbiJYI2m (ORCPT ); Tue, 25 Oct 2022 04:28:42 -0400 Received: from mail.nfschina.com (mail.nfschina.com [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 43EDAE984F; Tue, 25 Oct 2022 01:28:41 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id BA2AB1E80C8E; Tue, 25 Oct 2022 16:27:18 +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 Uuw8E96Tt7r7; Tue, 25 Oct 2022 16:27:16 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: zeming@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 300B21E80C82; Tue, 25 Oct 2022 16:27:16 +0800 (CST) From: Li zeming To: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Li zeming Subject: [PATCH] btrfs: volumes: Increase bioc pointer check Date: Tue, 25 Oct 2022 16:28:35 +0800 Message-Id: <20221025082835.3751-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?1747649230174388512?= If kzalloc fails to allocate the bioc pointer, NULL is returned directly. Signed-off-by: Li zeming Reviewed-by: Qu Wenruo --- fs/btrfs/volumes.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 064ab2a79c80..f9cb815fe23d 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -5892,6 +5892,8 @@ static struct btrfs_io_context *alloc_btrfs_io_context(struct btrfs_fs_info *fs_ */ sizeof(u64) * (total_stripes), GFP_NOFS|__GFP_NOFAIL); + if (!bioc) + return NULL; atomic_set(&bioc->error, 0); refcount_set(&bioc->refs, 1);