Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp137481iob; Tue, 17 May 2022 21:31:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzx7NCYhSplK2DxzaNSLnluGSX4jKLRKD6b1ldC6llbX+AxrRSTGvE+C7h/LfOtnrd8YYr7 X-Received: by 2002:a17:902:b788:b0:161:7f66:b9e0 with SMTP id e8-20020a170902b78800b001617f66b9e0mr12432864pls.73.1652848269686; Tue, 17 May 2022 21:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652848269; cv=none; d=google.com; s=arc-20160816; b=biVN8vDRoVCnMOvwLA9yoDDiuPq5Gnh6sQcaz/ht0gIbeCtMq0r1JFzrq/DWZtTuhs 9Puuph9O4ECyIN1NbY/NyDSJMTTvW8/+W79wtu6FFstb/4j5jl2PL22YEMkVqZjjhYt4 VOUYtG3alvuvFqyDzfLCixvujqdIakhk6eJi7+rkOmRUMbmQKHpgVBlLx4qIpmmpBMh+ Ps2ic8f/VTLzYPGeZNlSSqlRs/JfavNVpAKpOIp7kMpoMGVR/hjBr0sCpUBP7W340+/h R2Ad91mCRWdalj/2NPEQHX64VOXOSXdUivedw2BxNmw81roekLcBKauZ0NPVyblyaxgK j/sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:newsgroups:cc:to:content-language:subject:user-agent :mime-version:date:message-id; bh=2aAQoTxT4awpPPH9v+QCuo/GKZx6ZYo2pGxgHcI6WzQ=; b=NQCKAoJwBp9XYbW6iLtA9MjZ3q5QYQVfc704sB/cg+Y2DmAO4FIs6rix+5Zg0qdU7B XydPqbgMa/Q0zZcZfb4FPQK8lcKGXIzXbJXS9KosDJq5FtufMADnjsZorR+lgiJ/aMSl 3l8ICZdWMwFAOAWPnXiim78wMwe4F9UMYEM5CK69xhUzt5QL+a4bCMPnfvvD/tn6629H /INsNdQaV9Hcae7AIZfvLOLOTqbmuBZYOPaNKBYXiBBiowUIvs/OIHnD2aLaeyceC+zS Xy57pSDdgTJbhV9pBG8tvUmdJgXP397tLf5GPvApWgGUjNqY1SoNFOzjjflvDkQDwDpk TI6g== 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:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u22-20020a056a00125600b0050ddfec8631si1800110pfi.337.2022.05.17.21.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 21:31:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 402128148F; Tue, 17 May 2022 20:51:28 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347385AbiEQTmv (ORCPT + 99 others); Tue, 17 May 2022 15:42:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233185AbiEQTms (ORCPT ); Tue, 17 May 2022 15:42:48 -0400 Received: from smtp.smtpout.orange.fr (smtp02.smtpout.orange.fr [80.12.242.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A3A926AF9 for ; Tue, 17 May 2022 12:42:46 -0700 (PDT) Received: from [192.168.1.18] ([86.243.180.246]) by smtp.orange.fr with ESMTPA id r35enso0WEMbDr35enGE51; Tue, 17 May 2022 21:42:44 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Tue, 17 May 2022 21:42:44 +0200 X-ME-IP: 86.243.180.246 Message-ID: <301a1d0a-971b-5b27-c5a9-86390358de9a@wanadoo.fr> Date: Tue, 17 May 2022 21:42:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH] RDMA: remove null check after call container_of() Content-Language: en-US To: Jason Gunthorpe Cc: Dennis Dalessandro , Leon Romanovsky , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Haowen Bai Newsgroups: gmane.linux.drivers.rdma,gmane.linux.kernel References: <1652751208-23211-1-git-send-email-baihaowen@meizu.com> <20220517121646.GE63055@ziepe.ca> <142a9c03-574f-adcf-bc4d-bb2a25c01e88@wanadoo.fr> <20220517180303.GK63055@ziepe.ca> From: Christophe JAILLET In-Reply-To: <20220517180303.GK63055@ziepe.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, 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-kernel@vger.kernel.org Le 17/05/2022 à 20:03, Jason Gunthorpe a écrit : > On Tue, May 17, 2022 at 07:54:38PM +0200, Christophe JAILLET wrote: >> Le 17/05/2022 à 14:16, Jason Gunthorpe a écrit : >>> On Tue, May 17, 2022 at 09:33:28AM +0800, Haowen Bai wrote: >>>> container_of() will never return NULL, so remove useless code. >>> >>> It is confusing here, but it can be null. >> >> Hi, >> >> out of curiosity, can you elaborate how it can be NULL? > > It is guarented/required that that container_of is a 0 offset. The > normal usage of the ib_alloc_device macro: > > #define ib_alloc_device(drv_struct, member) \ > container_of(_ib_alloc_device(sizeof(struct drv_struct) + \ > BUILD_BUG_ON_ZERO(offsetof( \ > struct drv_struct, member))), \ > struct drv_struct, member) > > Enforces this property with a BUILD_BUG_ON > > So, if the input pointer to container_of is reliably NULL or ERR_PTR > then the output pointer will be the same. > > The rvt code here open codes the call because it is a mid-layer and > the sizeof() calculation above is not correct for it. > > Jason > Crystal clear. Thank you for the explanation. CJ