From patchwork Wed Feb 1 17:21:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Zhandarovich X-Patchwork-Id: 51491 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp408496wrn; Wed, 1 Feb 2023 09:31:35 -0800 (PST) X-Google-Smtp-Source: AK7set/M5+Fs57ycykqkSpyNVHeA+NNrtqvXJkvF9I7gln7rMXCL/+3M06bRDZHfL+RH472TFlSM X-Received: by 2002:a05:6a21:150f:b0:a3:8eb5:6869 with SMTP id nq15-20020a056a21150f00b000a38eb56869mr2955706pzb.14.1675272695135; Wed, 01 Feb 2023 09:31:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675272695; cv=none; d=google.com; s=arc-20160816; b=isl17MOkp/C19pHGXejSd3xN+4wAdyeYVIBILuu2gpMi/EjVsdlGctxiwlLT7rj2Kg ZF8isjhdfFwBtfWHrXCgsWF3obHdMkd0MUbzRHGDNMR7EBm7et/XlNHMRcI+vuEh+ZS/ u2+lfqJTQdRRCOW4n2S3yHpmf89orUCq2aSF5DeWHpfxXkQwfO3D5MLgCboasAZ3C/ph 1n8d3g5vVHIxHNER1NWA+LB5xbR2gUY8RkFPXEB8HyvwWZEGhppitzOCRI2E8OM+wVHy 8+fwzgMsC26EO5wUxjaK6D/ND8KPKaY6DHfbkH71HtpjUml4lYbMLC595VuQd3iieKFO V+Wg== 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; bh=2mbJBneXZf/WzpfDjeRK/gEew/r7BFjkdAgxny2OHrk=; b=dZ6dY48HXgjPkU+cLFw3Ew6/11BTXgu9Tc9CE1IWKGRmtGiXvVPyUTjrXnDP2VsDYS w8l59XvGZMmKf6UDKHe4QgbVC+cX3KStX9tLyyBDnqeIqfM20OiVPSQh7uRtIquw+rqy r4L7m25BYgS15vmIG+UmUfdbsch9irctj32dwdDqm4TZh4FFIlC9Tn/H7/uL5HwIMDB5 zBd7ZXeO/WNrrqNdjpEOYN/eI1Rnqv+HCqm/iqHPkaBafuGZ+s2fhPA8SxmPphldDjRZ KIKhyZig7II15cHLHDpiwDOCVEK16JQpTNa4krYq60JrRh+7MJ9A+LwR1zZu/pHAmI29 yKcw== 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 l193-20020a633eca000000b004cab626358csi20718543pga.485.2023.02.01.09.31.23; Wed, 01 Feb 2023 09:31:35 -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; 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 S232168AbjBARVb (ORCPT + 99 others); Wed, 1 Feb 2023 12:21:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232193AbjBARVX (ORCPT ); Wed, 1 Feb 2023 12:21:23 -0500 Received: from exchange.fintech.ru (e10edge.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C6DF7CCBE; Wed, 1 Feb 2023 09:21:10 -0800 (PST) Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.169) with Microsoft SMTP Server (TLS) id 14.3.498.0; Wed, 1 Feb 2023 20:21:08 +0300 Received: from localhost (10.0.253.157) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Wed, 1 Feb 2023 20:21:08 +0300 From: Nikita Zhandarovich To: Potnuri Bharat Teja CC: Nikita Zhandarovich , Jason Gunthorpe , Leon Romanovsky , Roland Dreier , Vipul Pandya , , , Subject: [PATCH] RDMA/cxgb4: add null-ptr-check after ip_dev_find() Date: Wed, 1 Feb 2023 09:21:03 -0800 Message-ID: <20230201172103.17261-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.0.253.157] X-ClientProxiedBy: Ex16-01.fintech.ru (10.0.10.18) To Ex16-01.fintech.ru (10.0.10.18) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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?1756650741681651163?= X-GMAIL-MSGID: =?utf-8?q?1756650741681651163?= ip_dev_find() may return NULL and assign it to pdev which is dereferenced later. Fix this by checking the return value of ip_dev_find() for NULL similar to the way it is done with other instances of said function. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 1cab775c3e75 ("RDMA/cxgb4: Fix LE hash collision bug for passive open connection") Signed-off-by: Nikita Zhandarovich --- drivers/infiniband/hw/cxgb4/cm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c index c16017f6e8db..07d0bafb7ac5 100644 --- a/drivers/infiniband/hw/cxgb4/cm.c +++ b/drivers/infiniband/hw/cxgb4/cm.c @@ -4151,6 +4151,10 @@ static int rx_pkt(struct c4iw_dev *dev, struct sk_buff *skb) if (neigh->dev->flags & IFF_LOOPBACK) { pdev = ip_dev_find(&init_net, iph->daddr); + if (!pdev) { + pr_err("%s - failed to find device!\n", __func__); + goto free_dst; + } e = cxgb4_l2t_get(dev->rdev.lldi.l2t, neigh, pdev, 0); pi = (struct port_info *)netdev_priv(pdev);