From patchwork Tue Nov 15 09:46:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Arefev X-Patchwork-Id: 20274 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2621336wru; Tue, 15 Nov 2022 02:01:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf6gjPzHnvJDrU2mnm/j3wEgjlyi5hNXH2/b5tGmO2au4iNwTJC6UVl3NuRk623bJXS9Vn8v X-Received: by 2002:a17:902:e541:b0:17f:6fee:3334 with SMTP id n1-20020a170902e54100b0017f6fee3334mr3447260plf.10.1668506509165; Tue, 15 Nov 2022 02:01:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668506509; cv=none; d=google.com; s=arc-20160816; b=uCr14frsCGRFPMxTuUXjx+7etAzqtv7ilkXcMmTAMXBfTXghTDrljbsohy0bFGmEyj 1x1qu0WPBups74BgBfuh4YEyHw1+ddcPEa0awWI/v4jk2YvifmW3Z6iMXEMCLepwhKxF R3WCgqqcWaX1qrh17Gzb6a2UmRig0jSJnpSfENLoMtw7OXLrCnTEHPbZPh0zLteWINib m0YNwvPugwjX/iVH38B6ZYdaMh1FNJ/S9+2TrM+610qKWUwVDUT9zPfTmm2IBYAbkqQp pRoMpJSPMEMRSqzJhYNBNIdu5M7ySQlmXzR72KYbVyPzDpVsCumm51/K6RKsrQNRJNc9 0qNw== 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 :message-id:date:subject:cc:to:dkim-signature:from; bh=NmmBGedzdtOQXgj14ZUnuEyKYV0y5hMfZTUePWXPEbw=; b=tlaZMBH8ufiW6K0rxmV6ud4o/Iwsds9ktAO46Prpa23rwypvrU6cWiBO1ZecrgpEWg ils1bYF9G+pI5eTn3Xz3fzU0B7nhuVx0k/TbpIH/idejJaBx/mq7d4Q7YN7w82Z6nlPc eCx224OXjjncOncZjFTHoKpyYobmORw6PfZdqJxiBwV2WK1USlk6y0C3A7O7MHyzmKZG /qdkUbb7Im0GZ46aa3pg/YOCp+NJq8P2LqjGQ6elfnPpH4vyVarYk1j5RwUWv85ektSS /BfNEFpUnaJ2AVl1JJlXM3+b4Oja8ShEf+RgaJa9MxojzJoZvJgEb7Y/uP+FwEf+0vs5 Hx6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b=sCnrEURW; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z13-20020a1709027e8d00b001869b988da6si10676386pla.402.2022.11.15.02.01.33; Tue, 15 Nov 2022 02:01:49 -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=@swemel.ru header.s=mail header.b=sCnrEURW; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232781AbiKOJyq (ORCPT + 99 others); Tue, 15 Nov 2022 04:54:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229911AbiKOJyn (ORCPT ); Tue, 15 Nov 2022 04:54:43 -0500 X-Greylist: delayed 491 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 15 Nov 2022 01:54:41 PST Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A802A38B4; Tue, 15 Nov 2022 01:54:41 -0800 (PST) From: Denis Arefev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1668505589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=NmmBGedzdtOQXgj14ZUnuEyKYV0y5hMfZTUePWXPEbw=; b=sCnrEURWR+mhGX/LBvib/yhHGHOmE4zVV2U/doO+IVBvQrtJncWxwXNCNNUrjtYNonMigQ 25UDg0jFSQy9FsokzFGug5hM05TlaLVgsvDQYVRVG03WeY4Ndn0Fpge0LBBHdNmuJR+UG6 IFkTwM3LAyK+D16v+pATt5G3w6PlBak= To: Karen Xie Cc: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , ldv-project@linuxtesting.org, trufanov@swemel.ru, vfh@swemel.ru Subject: [PATCH] cxgb4i : Added pointer check Date: Tue, 15 Nov 2022 12:46:29 +0300 Message-Id: <20221115094629.73591-1-arefev@swemel.ru> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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?1749555881106504376?= X-GMAIL-MSGID: =?utf-8?q?1749555881106504376?= Return value of a function 'alloc_wr' is dereferenced at cxgb4i.c:624 without checking for null, but it is usually checked for this function Signed-off-by: Denis Arefev --- drivers/scsi/cxgbi/cxgb4i/cxgb4i.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c index 2c3491528d42..40ed8e27945c 100644 --- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c +++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c @@ -611,7 +611,7 @@ static inline int tx_flowc_wr_credits(int *nparamsp, int *flowclenp) static inline int send_tx_flowc_wr(struct cxgbi_sock *csk) { - struct sk_buff *skb; + struct sk_buff *skb = NULL; struct fw_flowc_wr *flowc; int nparams, flowclen16, flowclen; @@ -620,6 +620,8 @@ static inline int send_tx_flowc_wr(struct cxgbi_sock *csk) #endif flowclen16 = tx_flowc_wr_credits(&nparams, &flowclen); skb = alloc_wr(flowclen, 0, GFP_ATOMIC); + if (!skb) + return -ENOMEM; flowc = (struct fw_flowc_wr *)skb->head; flowc->op_to_nparams = htonl(FW_WR_OP_V(FW_FLOWC_WR) | FW_FLOWC_WR_NPARAMS_V(nparams));