From patchwork Thu Jan 26 18:52:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Zhandarovich X-Patchwork-Id: 48854 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp435295wrn; Thu, 26 Jan 2023 11:01:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXthzBNayU6K9v76xHzPMRKag7Tu7fI7mfyw7kSzZrko9imp/HB4pskJvpvYQz+7LS9M7wSi X-Received: by 2002:a17:906:ce23:b0:85a:4230:6743 with SMTP id sd3-20020a170906ce2300b0085a42306743mr37398403ejb.23.1674759698782; Thu, 26 Jan 2023 11:01:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674759698; cv=none; d=google.com; s=arc-20160816; b=etdj9vkw0eRbjOLZEnB/+pP9CMiKzd6kPFicw9J6+UnC3FZeKKKQolRWtWIIe2sLLL vYnjAAR/NJgKrmA7TuHSeb9/hIsh4oU8AAJa1DkYfOVpHvYJQsu3JHW5suuq3TyFuYRS UlIjqU2T/wwifKNMW6gWGiO0wNDYjB4CeywgvovI5MoVb4UueAj+2bG8cCjKHiqd8zqb ZOUGTybl6zyslq80Qk3w0M0EXm10oqzulRdtijePZsqo4UfXzrlwpIXmLtUCXtaD4NOL PzSrhd+xU5XBnBIFZZs/n98DkNwPHqfsss2I33DlfsAeGtnlAlxSPn2C/xF5fqgFuvhk Ltkw== 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=et4kMqhTdN5ZIAEHmHEUwbEVKDdLP0sX9HttzWeE82c=; b=uxTiaPDvcx2h7EwxVg1QqadH2Bm5XPOsqGXuQVdFKPP8is/1neM/VMjpifS09+L4Hp QSPKHI7lr7utHJkGIGsDXLf36EKhKJlM/fFycWFpm4K7M6L/UZtRk4qDVh80CZ4KwGdR 6q0T9rwiiNN3wpSQewhPxLlqKHP+Rea6OBJxglijj5Zf00xQDC34V+evPBe62/8Nd15C TnpFX5da1rMswW/UPuLzQQknIN4ypuZupyEKyk+1kljNL8QwBM7a/Uw3huhGGWgWXObV O/8Jhf3rnhnWajeJvyb6dQUMxnd0zz96aaVKwlmOVu+Sn/YsnpGlNv/hZVAuQGxyb+v0 VKxA== 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 j9-20020a170906534900b00878563e8d67si2241827ejo.347.2023.01.26.11.01.15; Thu, 26 Jan 2023 11:01:38 -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 S232180AbjAZSwy (ORCPT + 99 others); Thu, 26 Jan 2023 13:52:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbjAZSwv (ORCPT ); Thu, 26 Jan 2023 13:52:51 -0500 Received: from exchange.fintech.ru (exchange.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59F2D76AC; Thu, 26 Jan 2023 10:52:48 -0800 (PST) Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.159) with Microsoft SMTP Server (TLS) id 14.3.498.0; Thu, 26 Jan 2023 21:52:39 +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; Thu, 26 Jan 2023 21:52:39 +0300 From: Nikita Zhandarovich To: Mustafa Ismail CC: Nikita Zhandarovich , Shiraz Saleem , Jason Gunthorpe , Leon Romanovsky , , , Subject: [PATCH] RDMA/irdma: Fix potential NULL-ptr-dereference Date: Thu, 26 Jan 2023 10:52:30 -0800 Message-ID: <20230126185230.62464-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?1756112825783660155?= X-GMAIL-MSGID: =?utf-8?q?1756112825783660155?= in_dev_get() can return NULL which will cause a failure once idev is dereferenced in in_dev_for_each_ifa_rtnl(). This patch adds a check for NULL value in idev beforehand. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 146b9756f14c ("RDMA/irdma: Add connection manager") Signed-off-by: Nikita Zhandarovich drivers/infiniband/hw/irdma/cm.c | 3 +++ 1 file changed, 3 insertions(+) Reviewed-by: Sindhu Devale diff --git a/drivers/infiniband/hw/irdma/cm.c b/drivers/infiniband/hw/irdma/cm.c index 7b086fe63a24..195aa9ea18b6 100644 --- a/drivers/infiniband/hw/irdma/cm.c +++ b/drivers/infiniband/hw/irdma/cm.c @@ -1722,6 +1722,9 @@ static int irdma_add_mqh_4(struct irdma_device *iwdev, continue; idev = in_dev_get(ip_dev); + if (!idev) + continue; + in_dev_for_each_ifa_rtnl(ifa, idev) { ibdev_dbg(&iwdev->ibdev, "CM: Allocating child CM Listener forIP=%pI4, vlan_id=%d, MAC=%pM\n",