Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2554284rdb; Fri, 22 Sep 2023 01:54:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF635LGhEkiOkEnkg0GDPvRFNRl4eo+BgjPrOijKoOIZekzEt8U1aJ2NrRPGkEaPQZmTf/7 X-Received: by 2002:a05:6a00:c91:b0:68f:ece2:ac2a with SMTP id a17-20020a056a000c9100b0068fece2ac2amr7884627pfv.27.1695372841060; Fri, 22 Sep 2023 01:54:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695372841; cv=none; d=google.com; s=arc-20160816; b=AmsmtyajOBunJ0iku1G/tQz40W8kelAy17ywhU5Om2ccrGosoQZAYSKrMaL2JOAYER /08XLIfBSPNHYY3PwuuPafOx58DmGaUImhz/XxLI1V7yKk4DNHQe+IKFQNo8rbaiWL6M sCiaCBPR0eenbIW65wX8bxrKeEfb3ewkVWq8NZYI6KvNJ5ARy/CD4crje34As5KA66am M03I80Z/TsIhKMfvoSt2ZR0pbOR6xGdGt2TZG1+auTUJWOKjnIvTC7xlAqfptLOaLRLq DpBgxs3XsPfk1C7I+9gAM5DkDJ+DHCloWsSVzF7XdxOxqBspZbAspPtDNwLD0ygPtwzj Wi5w== 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=7XbAhG3lFB6c4GQ9Qg147W2lRJqCi34MiuDSezdWuAA=; fh=lHUrI8dAXAuE5S8VFEejJUpTwCAk3MankmLMJp4dvQA=; b=bWmNA+xHyKn4W/G4o+f+6hptMKnXZ8r2wKVgixwbdc/7QiW2yd1MiT4DWbUlIhhPkW 6BvIY7GfmoMNOCYV9ig529lKLviqop4TqqKB9dPEWmx43OK5qVMWVKep4Hk75P4ZOX7R j2ZVAWhLl9KdPh28V//OqO9lUPUBu88DKvGP2cnefOiEQJ2OE2yJ8Jgt4ctW5sXrbxvE UC6I5fM5trHw3rQicCWWZpX5wFC4vYBY7c4SZywu+IsuFTW71X7Y13kuneEC11v0E/8A zS/ftEYktLdBCnGwULR3tepkoas+jzMtQ0jcCNiBazRSdDV4xCf1ZOdFpQOphLDznxZ+ 27Uw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id e9-20020a636909000000b0056a9544e894si3284297pgc.397.2023.09.22.01.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 01:54:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 3B05C80DD6AD; Fri, 22 Sep 2023 01:16:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232530AbjIVIQJ (ORCPT + 99 others); Fri, 22 Sep 2023 04:16:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232509AbjIVIPe (ORCPT ); Fri, 22 Sep 2023 04:15:34 -0400 Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 727311B7; Fri, 22 Sep 2023 01:05:26 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R431e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0VscdTnn_1695369923; Received: from 30.221.128.225(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0VscdTnn_1695369923) by smtp.aliyun-inc.com; Fri, 22 Sep 2023 16:05:23 +0800 Message-ID: <2c9d570c-f780-0484-a26c-78b115e1a6a3@linux.alibaba.com> Date: Fri, 22 Sep 2023 16:05:22 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH net-next 01/18] net/smc: decouple ism_dev from SMC-D device dump To: Simon Horman Cc: kgraul@linux.ibm.com, wenjia@linux.ibm.com, jaka@linux.ibm.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, alibuda@linux.alibaba.com, tonylu@linux.alibaba.com, linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <1695134522-126655-1-git-send-email-guwen@linux.alibaba.com> <1695134522-126655-2-git-send-email-guwen@linux.alibaba.com> <20230921204153.GQ224399@kernel.org> From: Wen Gu In-Reply-To: <20230921204153.GQ224399@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 22 Sep 2023 01:16:27 -0700 (PDT) On 2023/9/22 04:41, Simon Horman wrote: > On Tue, Sep 19, 2023 at 10:41:45PM +0800, Wen Gu wrote: >> This patch helps to decouple ISM device from SMC-D device, allowing >> different underlying device forms, such as virtual ISM devices. >> >> Signed-off-by: Wen Gu >> --- >> net/smc/smc_ism.c | 8 +++++--- >> 1 file changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c >> index fbee249..0045fee 100644 >> --- a/net/smc/smc_ism.c >> +++ b/net/smc/smc_ism.c >> @@ -230,12 +230,11 @@ static int smc_nl_handle_smcd_dev(struct smcd_dev *smcd, >> char smc_pnet[SMC_MAX_PNETID_LEN + 1]; >> struct smc_pci_dev smc_pci_dev; >> struct nlattr *port_attrs; >> + struct device *priv_dev; >> struct nlattr *attrs; >> - struct ism_dev *ism; >> int use_cnt = 0; >> void *nlh; >> >> - ism = smcd->priv; >> nlh = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, >> &smc_gen_nl_family, NLM_F_MULTI, >> SMC_NETLINK_GET_DEV_SMCD); >> @@ -250,7 +249,10 @@ static int smc_nl_handle_smcd_dev(struct smcd_dev *smcd, >> if (nla_put_u8(skb, SMC_NLA_DEV_IS_CRIT, use_cnt > 0)) >> goto errattr; >> memset(&smc_pci_dev, 0, sizeof(smc_pci_dev)); > > Hi Wen Gu, > > priv_dev is uninitialised here. > >> - smc_set_pci_values(to_pci_dev(ism->dev.parent), &smc_pci_dev); >> + if (smcd->ops->get_dev) >> + priv_dev = smcd->ops->get_dev(smcd); > > It is conditionally initialised here. > >> + if (priv_dev->parent) > > But unconditionally dereferenced here. > > As flagged by clang-16 W=1, and Smatch > Hi Simon. Yes, I fixed it in v3. Thank you! >> + smc_set_pci_values(to_pci_dev(priv_dev->parent), &smc_pci_dev); >> if (nla_put_u32(skb, SMC_NLA_DEV_PCI_FID, smc_pci_dev.pci_fid)) >> goto errattr; >> if (nla_put_u16(skb, SMC_NLA_DEV_PCI_CHID, smc_pci_dev.pci_pchid)) >> -- >> 1.8.3.1 >> >>