Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp59437pxh; Thu, 7 Apr 2022 13:57:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPzk153oF9UaTiy9h1ooDruYKxE7KrTM9TAtk7CpXk8Ec/SstGb0JuHepR2paLCqvjB2nv X-Received: by 2002:a17:90a:8581:b0:1b2:7541:af6c with SMTP id m1-20020a17090a858100b001b27541af6cmr17992134pjn.48.1649365058079; Thu, 07 Apr 2022 13:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649365058; cv=none; d=google.com; s=arc-20160816; b=qzv6i0/lWQNQH9yhD75loCdmHhK0dOBSXGqLGqE/p28S2IoLo+Ra0c4wmQlEL6SY3N 3C4IN84R3leAIPWJByPytuAN/1FnHAVwL1Szv+jGFDlDbjU6Bocvo41f8j/rUmWEWLy6 X0n9SFiwAutAPpZgzdHvT+oCMjSaf2DmGgSU7c8rrLnPVtJ+cE5FLA3/W5O26cx1YfgC /aopH2awC2I6SKVhutZdFQyNBoI5PfpfO+idp9tiHtpn/lOP5W/SXO2iPxwnvmJbmsLx I69b34XZSidDqFTckLRkPG7jbr2+h94E0uxgOB2p+JemTCLd5+1nNBbjqmaOdX/eu+aO Wl9Q== 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 :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=3dF3vE6LBnI3yPoo+6Q3Z6veU6UqNj7dfKqWcUdcKk4=; b=k7ccRGGDyUUEX7mXaiPJwzvBDNwo2Dh7cD5I5RcNSFoPru3u8w5I43b6equM0pXnJ3 Ud8CyQw9TeadUpqc+cD3zmHrg34VaiLzFjwHDnMc4Pc7h6SvHrnzdu8tzpLhdp7oJz30 hCvlyYbCcnwWbRIIRZWlGOsfXi0nci+kpYAydpYh6AYs3fBm0ZquU7EUPa4xAhuG8uw7 3UEpe0llfz4T11JLAaSx4h/zdMi1exZK78nlH3XeTrJdnch4qPQibwOmgddkwIFDK4W+ v5QyWmg4y0aT9m96dRFwgfW7+3/bJE4WZC/iOp3Z9CZaHOynl6MzxlsTsK+Gu1HjPoiD Hchw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="HhOib/X3"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b10-20020a17090a488a00b001c68967d8f1si2593573pjh.80.2022.04.07.13.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:57:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="HhOib/X3"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 29E35411F26; Thu, 7 Apr 2022 13:00:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345182AbiDGPq5 (ORCPT + 99 others); Thu, 7 Apr 2022 11:46:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345130AbiDGPqh (ORCPT ); Thu, 7 Apr 2022 11:46:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89281C6EE8 for ; Thu, 7 Apr 2022 08:44:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CDB8761EC1 for ; Thu, 7 Apr 2022 15:44:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60A94C385A9 for ; Thu, 7 Apr 2022 15:44:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649346273; bh=BjRUl9xvDLy47XQuB0DZe/W57Oa4+dauIzR16hGbzfc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HhOib/X3kHKzYQExPiWMCycdjhRV24omFy65rADXtDTk+tc9T3xe57qjJ4l8JwOXK VMQfcmvqD5LHP/lkJHowaJIU9Qsvx76zBLaDeNEPSadkyWCAkJa9SfUeEbLBpxkH+k rKM0Ru8x8irTgT6+7DwN8aOWNsQ0uJN07lcOUTUtWrzzvRTnCyRJuzWtSj0PqZtKaB /Qchby9aCySMd+qW2cHy1cbrDETtYoQ6OspW+Ih4FyStnuSfjysmGVjiC3okSDJdWP w25QQY9YCBqQ23kMhkCfc0h8zo63Z1Pu6IzghvGenKsFkbAH54dFXLVjHMQ/uWtA0y 8pQwZoMngzOfg== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH 6/7] SUNRPC: Handle allocation failure in rpc_new_task() Date: Thu, 7 Apr 2022 11:38:08 -0400 Message-Id: <20220407153809.1053261-6-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220407153809.1053261-5-trondmy@kernel.org> References: <20220407153809.1053261-1-trondmy@kernel.org> <20220407153809.1053261-2-trondmy@kernel.org> <20220407153809.1053261-3-trondmy@kernel.org> <20220407153809.1053261-4-trondmy@kernel.org> <20220407153809.1053261-5-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-nfs@vger.kernel.org From: Trond Myklebust If the call to rpc_alloc_task() fails, then ensure that the calldata is released, and that rpc_run_task() and rpc_run_bc_task() bail out early. Reported-by: NeilBrown Signed-off-by: Trond Myklebust --- net/sunrpc/clnt.c | 7 +++++++ net/sunrpc/sched.c | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 6757b0fa5367..af0174d7ce5a 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -1127,6 +1127,8 @@ struct rpc_task *rpc_run_task(const struct rpc_task_setup *task_setup_data) struct rpc_task *task; task = rpc_new_task(task_setup_data); + if (IS_ERR(task)) + return task; if (!RPC_IS_ASYNC(task)) task->tk_flags |= RPC_TASK_CRED_NOREF; @@ -1227,6 +1229,11 @@ struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req) * Create an rpc_task to send the data */ task = rpc_new_task(&task_setup_data); + if (IS_ERR(task)) { + xprt_free_bc_request(req); + return task; + } + xprt_init_bc_request(req, task); task->tk_action = call_bc_encode; diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index b258b87a3ec2..7f70c1e608b7 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -1128,6 +1128,11 @@ struct rpc_task *rpc_new_task(const struct rpc_task_setup *setup_data) if (task == NULL) { task = rpc_alloc_task(); + if (task == NULL) { + rpc_release_calldata(setup_data->callback_ops, + setup_data->callback_data); + return ERR_PTR(-ENOMEM); + } flags = RPC_TASK_DYNAMIC; } -- 2.35.1