Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp531111rwl; Fri, 7 Apr 2023 01:00:08 -0700 (PDT) X-Google-Smtp-Source: AKy350apCti/dp8Ti3rYgyVZZYDhoiWICf+G7ysomdJCyB6Lygy7Kufd45UM2m4R3MUJEznM8mMd X-Received: by 2002:a17:90a:bf0c:b0:23a:340d:fa49 with SMTP id c12-20020a17090abf0c00b0023a340dfa49mr1449468pjs.32.1680854408558; Fri, 07 Apr 2023 01:00:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680854408; cv=none; d=google.com; s=arc-20160816; b=S3TUMEn5CprOAWlp20xJjnLqr/7YMTfoDXMh27cB5i1mzYVlmUj55bjj7p+V9+crVk H5xM3oPhSxXEM3SgacUl3M2dqj9R3+/dxmqGFp5E7/x6YGNj8YlN4mlNluwz1QAem5H9 F5m2X0wz6VmnhOTQ5sQMLKURbTKt1/KmhwdLe1gl2iDdSuA9E8GMC7zEHm06ZD319Mc0 XsfGKDCATMWtNirYNVnFobYR6yHckuA9TTVJWeajgRZCIAkixl1JG9mel8NK/kjfwRhd KxYyWT19V1x7SEFB5qfvIUEmAXrjgJHDZqIbxhLKAsdRG5H7YTxB9Hl0tv4H2nGb0RWM kdbw== 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:from:dkim-signature; bh=9IRxraDMMRQpsr1I0/AtgfXObZe/EMARKPhOMkXb224=; b=AvJ+AQ6PIVH3srELS5beNcoyoEew9yBRwl5IpIgKHoKcHsKkT3ph93IdwFoTTl9vO0 ERE8hwpPMd7rIpoyDkuszc3h1GRF17CDxmtNf23iEQj2JrzOZn1dVXrF5rlQwhTpzH4A aflWyTF2v6p//rW9n+SEnZOf4nOZ+7hAJfDnB1EMJB4jTfv25liyRg2VSUomdWwROfBp 23/HkPtNFTKcoA7OXXApRyP4eCaSxcA0WjV7nJigVhNmQM4LrPTC2CrOMET+xJ+BQFKQ 4YuzhCK1Y92CNJiRaJr42D0W6JgDsnXcXpcOj2i35Nw6q46iFSEEW7RQHTvpjgEy2NQY HxBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=AQ7A+3uO; 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=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t5-20020a17090a3e4500b002307345bf7bsi5736357pjm.23.2023.04.07.00.59.56; Fri, 07 Apr 2023 01:00:08 -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; dkim=pass header.i=@yandex-team.ru header.s=default header.b=AQ7A+3uO; 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=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230265AbjDGH4T (ORCPT + 99 others); Fri, 7 Apr 2023 03:56:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230292AbjDGH4S (ORCPT ); Fri, 7 Apr 2023 03:56:18 -0400 Received: from forwardcorp1b.mail.yandex.net (forwardcorp1b.mail.yandex.net [IPv6:2a02:6b8:c02:900:1:45:d181:df01]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A37EA6E82; Fri, 7 Apr 2023 00:56:15 -0700 (PDT) Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:1fa8:0:640:3b74:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id B289C60305; Fri, 7 Apr 2023 10:56:13 +0300 (MSK) Received: from den-plotnikov-w.yandex-team.ru (unknown [2a02:6b8:b081:b507::1:25]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 4uLCdL0Od4Y0-uxaYAqh0; Fri, 07 Apr 2023 10:56:12 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1680854172; bh=9IRxraDMMRQpsr1I0/AtgfXObZe/EMARKPhOMkXb224=; h=Message-Id:Date:Cc:Subject:To:From; b=AQ7A+3uOBUEd0Xyw+fiUlB71zePlD05ZZbCypGYm4x0vtYJabG9mSKChjUoKmq1hv 2WuOSSIkHlGl5eNRKV5EQ4AGMwLNqxLuHWaJHgNDJXshznZesMPIRy9YdrZLHw0sR0 bnhF+GKdsMNU3+NLCXHQUV8BXKLot1lldfKkPXoQ= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Denis Plotnikov To: linux-scsi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, target-devel@vger.kernel.org, martin.petersen@oracle.com, nab@linux-iscsi.org, varun@chelsio.com, den-plotnikov@yandex-team.ru Subject: [PATCH] cxgbit: check skb dequeue result in cxgbit_send_tx_flowc_wr() Date: Fri, 7 Apr 2023 10:56:03 +0300 Message-Id: <20230407075603.311230-1-den-plotnikov@yandex-team.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org Skb dequeuing may end up with returning NULL if a queue is empty, which, in turn, may end up with further null pointer dereference. Fix it by checking the return value of skb dequeuing end returning before the pointer dereference. Found by Linux Verification Center(linuxtesting.org) with SVACE. Fixes: 9730ffcb8957 ("cxgbit: add files for cxgbit.ko") Signed-off-by: Denis Plotnikov --- drivers/target/iscsi/cxgbit/cxgbit_cm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/target/iscsi/cxgbit/cxgbit_cm.c b/drivers/target/iscsi/cxgbit/cxgbit_cm.c index d9204c590d9ab..426a5c795fd93 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit_cm.c +++ b/drivers/target/iscsi/cxgbit/cxgbit_cm.c @@ -1424,10 +1424,13 @@ u32 cxgbit_send_tx_flowc_wr(struct cxgbit_sock *csk) #ifdef CONFIG_CHELSIO_T4_DCB u16 vlan = ((struct l2t_entry *)csk->l2t)->vlan; #endif + skb = __skb_dequeue(&csk->skbq); + + if (!skb) + return 0; flowclen16 = cxgbit_tx_flowc_wr_credits(csk, &nparams, &flowclen); - skb = __skb_dequeue(&csk->skbq); flowc = __skb_put_zero(skb, flowclen); flowc->op_to_nparams = cpu_to_be32(FW_WR_OP_V(FW_FLOWC_WR) | -- 2.25.1