Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp134838iob; Tue, 17 May 2022 21:25:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaqH5+u3BOG0l75AN5UzxlCmt31ACYuOhQguXJX4IGaaYGfAgKElrIthMRl2dVqA1iqoMD X-Received: by 2002:a17:90a:1b82:b0:1df:2d80:b2ad with SMTP id w2-20020a17090a1b8200b001df2d80b2admr18805804pjc.67.1652847928660; Tue, 17 May 2022 21:25:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652847928; cv=none; d=google.com; s=arc-20160816; b=sdz51ArNH+/8Yq4z7lSQLpr0ENBjJ3Xzx129Whg38sEFeC7Q2ZpO0Bia9MF8lBmAHf a1PGTjbh+MHMiKqQV/FsDTeYFDFkTVNY2Q/GPvVClolhlVQUpaAlMbQjPCAhqzGOHU8f 8TlPg2O5eMTmrbNPlxLkmkoAqzw6SqlD7IzNhrE1QUTr4aqIR3t13GvTg3T24427Wz+s +zqdfyopNRJv7i0ZYVUcI46CZP9j9PnoJiOT3HxkFT+52XJrTU3Ci7g8nx8lQonOtFic 8tAV++kPfhAAEmxDGNrBK7ASQcEvep60sRDZreGiSygVgVB9EFXMkFC9Ax7OaEADHQrw rudw== 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:cc:to:subject:user-agent:mime-version:date:message-id; bh=solOOgyij81+WaN0LK/QSn+2kRVfjjJJaQvPHAiPr34=; b=cacFsgMTHpBQ0u6aCVfW35NBEVrpk7EdcPDc2dP88YuXKsrU9w9T/qJ8XJBW4V6IHM m7h/vAjZIuhRMo9sEiVwUofH/ptkSFJZSh/GtRDzgOcLv3xDteDFWxuVsgOQZtrLZN9r 1A7nOxk88n6NrTByV5P30X5cKtnaPl0wTM1RLMwi17dQutJFIYoCstmZuLOb0QrQTWDx hzsMjDOB9NXz5XrOK2CdceIlZQKwavLCfwlaNtKrgfr8Mt4U3+wk4Jn0ORHQIibUwzUm SpfBjFTExyG2bbpGFuU7AS9obM/441jdxCwoxkUvdH/4WoGHj9L3Z8Q/vMTOkJMs3R9M c57g== 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 v22-20020a056a00149600b0050dc2c62201si1721809pfu.65.2022.05.17.21.25.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 21:25:28 -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 8C359A76C3; Tue, 17 May 2022 20:49:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234017AbiERBzr (ORCPT + 99 others); Tue, 17 May 2022 21:55:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233998AbiERBzp (ORCPT ); Tue, 17 May 2022 21:55:45 -0400 Received: from mail.meizu.com (edge05.meizu.com [157.122.146.251]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E0C638D; Tue, 17 May 2022 18:55:40 -0700 (PDT) Received: from IT-EXMB-1-125.meizu.com (172.16.1.125) by mz-mail12.meizu.com (172.16.1.108) with Microsoft SMTP Server (TLS) id 14.3.487.0; Wed, 18 May 2022 09:55:38 +0800 Received: from [172.16.137.70] (172.16.137.70) by IT-EXMB-1-125.meizu.com (172.16.1.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Wed, 18 May 2022 09:55:38 +0800 Message-ID: Date: Wed, 18 May 2022 09:55:37 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH] RDMA: remove null check after call container_of() To: Jason Gunthorpe , Christophe JAILLET CC: Dennis Dalessandro , "Leon Romanovsky" , , 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: baihaowen In-Reply-To: <20220517180303.GK63055@ziepe.ca> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [172.16.137.70] X-ClientProxiedBy: IT-EXMB-1-126.meizu.com (172.16.1.126) To IT-EXMB-1-125.meizu.com (172.16.1.125) 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 在 2022/5/18 上午2:03, Jason Gunthorpe 写道: > 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 Thank you for the explanation.   : ) -- Haowen Bai