Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8084135rwl; Tue, 10 Jan 2023 08:52:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXsa/Ult/x+Uxd7WlyN2ZL1rt0e1r0VPcEhxNSzrWsvmZKpHCZaY+I9US3DWZ90pFs1zc0Aq X-Received: by 2002:a17:906:30d3:b0:838:9b81:1c98 with SMTP id b19-20020a17090630d300b008389b811c98mr56483832ejb.1.1673369547117; Tue, 10 Jan 2023 08:52:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673369547; cv=none; d=google.com; s=arc-20160816; b=RChz9N5NapN69Nir+smNdHeEZ6vSgKCc8yeJUNbYVakFOQcnpYA0rULhsWXMDka8rt 4MeSNdPB5U8qAygh6nJyST2yttPoGAxiLqouJ6ys1ApAXTIZ2NWs+5xGFs+795GgB2aJ Wpq7lrBRGWHe2DBLN6BDQZkz4Wpdm5lKWQks6FMn3Day1qVigsGMq2Nm9X4DudnhxZgN //9aXGA0KX2ITmoSfXEu3uBohA9aCsy7F9rK5ind284NlXX0So3/u29t3j+1PReGg/D/ 2OXxZ+Qok1nhO8sJdryMAhIo4C91B4tTqfTWzMm43qgo4Howz4yTZsJzTGfpIiKHksv0 Uz3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=lJePnZsKXnubDcGA3DYzaayBveLdWQPssGSlTfWc4l8=; b=IBpjgVwDoQlhWS1+Zi6Q11IuNOEhIxI6c0j90dDi+lTxaybjTpuIchox8HUNwa3gqa 608XWz8kn//cdk/XhsQpKSd6N3uAC3B4eyVN5IzGDCImbj9Cl8zyqxJAWVYfcwoPAwZj 87bNIReGl5oZBW843LNO4PtS9THtUV/ovfCzJ3Fz1pn9r/npZa2eW71enfXG5KnMxYEz cxJ1fEUhRM9ly5xOwyCGl8altTs027/LcAhnzx2bopRdkVJpo+90Bl0Cn1qChZRZN3DF 2uu+11ppPFz/AChDxF/9hr97u7oi9gX0clB+NP/ebR0SoaZaEG9SFcklsBoKS8TXBNzC ohOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TVodgAXQ; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw16-20020a170906479000b0078d9d67841fsi12542033ejc.400.2023.01.10.08.51.58; Tue, 10 Jan 2023 08:52:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TVodgAXQ; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238735AbjAJQtf (ORCPT + 99 others); Tue, 10 Jan 2023 11:49:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238561AbjAJQt2 (ORCPT ); Tue, 10 Jan 2023 11:49:28 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96494216 for ; Tue, 10 Jan 2023 08:48:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673369320; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lJePnZsKXnubDcGA3DYzaayBveLdWQPssGSlTfWc4l8=; b=TVodgAXQv+xTQHZdt2rKYeMfVOTOBMl1yTTiaHRGOz6fGYmsBvN0F8bCjlzvrEB4USFwEU iCWjVXInJFw+mSOzqBOoaa3uF64nNHPwXuqma9NQHeEXIKXrAEwaUSN2sF5P0RfhGyeX+m a0U5pCHXOPwICIhj2DrwEtF3ttPy1hk= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-66-qf-GHNnBO7OWRxoPdjUyMA-1; Tue, 10 Jan 2023 11:48:39 -0500 X-MC-Unique: qf-GHNnBO7OWRxoPdjUyMA-1 Received: by mail-pj1-f70.google.com with SMTP id t12-20020a17090a3e4c00b00225cb4e761cso5100423pjm.3 for ; Tue, 10 Jan 2023 08:48:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-language:content-transfer-encoding:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lJePnZsKXnubDcGA3DYzaayBveLdWQPssGSlTfWc4l8=; b=Wawydch+o3fFiBSAIXmxNr0YAhdtpvPae02j7kyzGUhjm9QUREeztbCUzVJlMET3aw vZtOpUm7J3jhWWq6cmZ1aF8qmQOfeGi79MVKZU4Sp644i4zVxEfFN4cZ4bMje1KJJGm+ BsnM0eWyncabCv4NuwYEFKaHRfSAzxmxtv/LeCsQMOjT+9RcLhfsBUyQnORJW5xs9Pel 4Wd+bfZirpW6sFIcjQPplQuwDQ68M3wgV4u70OfyDcqlYJGajBpYKRiYdvaWboWpaV0j Iqmk+62oixie63mjma0O9awyYwxQo8yzHlqKkNHGb0I8ltQoO7Db52yG+52u7i8Ttdj0 mmOQ== X-Gm-Message-State: AFqh2krKY1H3aLwU4bk/ydIdQ7XZrmCdGDWxYDvJziA0IIRoSgFSI9J7 oAKG/hXaiTMTD0mBHBoHlp2dkI230KJV3NpjvZvrg7EUG1KBQCI7llIKeDRgjE4727541mKzeZQ 1UxUMuhVJBfxK1OQJOwt1z/WR X-Received: by 2002:a17:902:8c90:b0:192:a470:2c0b with SMTP id t16-20020a1709028c9000b00192a4702c0bmr36292902plo.49.1673369318518; Tue, 10 Jan 2023 08:48:38 -0800 (PST) X-Received: by 2002:a17:902:8c90:b0:192:a470:2c0b with SMTP id t16-20020a1709028c9000b00192a4702c0bmr36292883plo.49.1673369318177; Tue, 10 Jan 2023 08:48:38 -0800 (PST) Received: from localhost.localdomain (024-205-208-113.res.spectrum.com. [24.205.208.113]) by smtp.gmail.com with ESMTPSA id l7-20020a655607000000b00477bdc1d5d5sm7061400pgs.6.2023.01.10.08.48.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Jan 2023 08:48:37 -0800 (PST) Subject: Re: [PATCH] crypto: initialize error To: Peter Gonda Cc: brijesh.singh@amd.com, thomas.lendacky@amd.com, john.allen@amd.com, herbert@gondor.apana.org.au, davem@davemloft.net, nathan@kernel.org, ndesaulniers@google.com, rientjes@google.com, marcorr@google.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev References: <20230110161831.2625821-1-trix@redhat.com> From: Tom Rix Message-ID: Date: Tue, 10 Jan 2023 08:48:33 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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-crypto@vger.kernel.org On 1/10/23 8:27 AM, Peter Gonda wrote: > On Tue, Jan 10, 2023 at 9:18 AM Tom Rix wrote: >> clang static analysis reports this problem >> drivers/crypto/ccp/sev-dev.c:1347:3: warning: 3rd function call >> argument is an uninitialized value [core.CallAndMessage] >> dev_err(sev->dev, "SEV: failed to INIT error %#x, rc %d\n", >> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> >> __sev_platform_init_locked() can return without setting the >> error parameter, causing the dev_err() to report a gargage > garbage ok > >> value. >> >> Fixes: 3d725965f836 ("crypto: ccp - Add SEV_INIT_EX support") > Should this be: 'Fixes: 200664d5237f ("crypto: ccp: Add Secure > Encrypted Virtualization (SEV) command support")' > > Since in that patch an uninitialized error can be printed? It was a bit of a toss up on who is at fault. This is fine, i'll change this as well. Thanks Tom > +void psp_pci_init(void) > +{ > + struct sev_user_data_status *status; > + struct sp_device *sp; > + int error, rc; > + > + sp = sp_get_psp_master_device(); > + if (!sp) > + return; > + > + psp_master = sp->psp_data; > + > + /* Initialize the platform */ > + rc = sev_platform_init(&error); > + if (rc) { > + dev_err(sp->dev, "SEV: failed to INIT error %#x\n", error); > + goto err; > + } > > > ... > > +static int __sev_platform_init_locked(int *error) > +{ > + struct psp_device *psp = psp_master; > + int rc = 0; > + > + if (!psp) > + return -ENODEV; > + > + if (psp->sev_state == SEV_STATE_INIT) > + return 0; > > > So if !psp an uninitialized error is printed? > >> Signed-off-by: Tom Rix >> --- >> drivers/crypto/ccp/sev-dev.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c >> index 56998bc579d6..643cccc06a0b 100644 >> --- a/drivers/crypto/ccp/sev-dev.c >> +++ b/drivers/crypto/ccp/sev-dev.c >> @@ -1307,7 +1307,7 @@ EXPORT_SYMBOL_GPL(sev_issue_cmd_external_user); >> void sev_pci_init(void) >> { >> struct sev_device *sev = psp_master->sev_data; >> - int error, rc; >> + int error = 0, rc; >> >> if (!sev) >> return; >> -- >> 2.27.0 >>