Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8086381rwl; Tue, 10 Jan 2023 08:54:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXu7A/uJpHN/7C8dCIzEMkkkA5PulG16pTJrMZeMcXh4IWJpdbQaVCIhQErurMbAt/B1r+h6 X-Received: by 2002:a17:906:a04f:b0:831:a76:90c0 with SMTP id bg15-20020a170906a04f00b008310a7690c0mr71452505ejb.32.1673369663675; Tue, 10 Jan 2023 08:54:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673369663; cv=none; d=google.com; s=arc-20160816; b=WNhuL+pLwueHnEZVdLWlWS8x9du54Yx07MycOkCYOpxzVwP7Q6isz0tOVUutpRuNky ZheyFBxdu6kvwF90fdQ9lfBwdjimbMDSuh6k8UggH4IlIIrcXnrjRF3fupS+clAAKW0C YHbNH9dXkirlfDZ6hRhuKnUZCruzqDvqHBAuwUYbd6R7ZGGEuSbFRZJVpPnVuzBPenQQ PIXEfnzcv6TKX7mRlub4d5QnvDYINPApLHozYIl/+d6L0Ibt1MuDH4nnBbdrbLRz5Uu+ XtPR1AHO7NwSax+sMm6qL/TB2oIBBHiKGThcacxGpZGOdypfIB86SD5xtdPauSxmXw+0 W9SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=UHlQmz4MZPCYm9BygwyVFf2S1z6UZf0NIZ7PiPTX9pQ=; b=RNPPrghC3tvGK788vrDSZf/mf1HkqzOmTYQKBb0+iotEDhgivYJEph3Y2gpk9AvPp2 3Ld3uVNBkXCbPnvGecYapiUfbpyaK21aovx8a0kFnVx6hAeb0rVbt4ciZDlYqlQJuNUf MU8CVF9oPBybnmWtG+DlvsrcKlJKnD2epR0H+qKY8wKkc3ykjIi8umKQAzpWmZfaoPHC ElIbtGU/JOVJaNUpCTdpLgMJeJju1AwAEH0Uc5qXMQJDWF/JPWJA8gCCNbsxmh9G0poM NWyWdpqwW6Nn2m9I6g8QW0OJyM1T099BMkbgWcywG3u3uLTQd4VxjBWdiXKRr1rjwaQ9 v8qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=eOEttK62; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dd7-20020a1709069b8700b007ad9c8201e7si14876299ejc.93.2023.01.10.08.54.00; Tue, 10 Jan 2023 08:54:23 -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=@google.com header.s=20210112 header.b=eOEttK62; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230452AbjAJQxu (ORCPT + 99 others); Tue, 10 Jan 2023 11:53:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238958AbjAJQxq (ORCPT ); Tue, 10 Jan 2023 11:53:46 -0500 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC2E2140BF for ; Tue, 10 Jan 2023 08:53:45 -0800 (PST) Received: by mail-lj1-x22c.google.com with SMTP id e13so13204512ljn.0 for ; Tue, 10 Jan 2023 08:53:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=UHlQmz4MZPCYm9BygwyVFf2S1z6UZf0NIZ7PiPTX9pQ=; b=eOEttK62GmXf0jQCMYIlYh623FQaOyPteJMvs+9gqBGF2BiED7YcvXEXCQPyMkpRna MqDTI5zO2JB7sPi8MMKGgWs8qHzcu9xaZ7kdKe94nzBkUQ9Ap0b9Iririg90SObGYe7c 8mJfMbLaBJZqUbjXfMtt3E2BiHD58XiS6O9d3KpR4Z8Zd09eOfoBHNOal/QxXg1o7/Ih uLmjZ4/fl5d3uEtnyqwezEPLSWsEcpm1iCjMv056cTVE7Gw2huxUTiP08y8uqLZ4a1DQ 1HxRNgQm74sTDb7Q2vmwJtBDjCZPgF38SMqoHI5W6WqeeYufRsMzfpvB5cidW0191Gah ynDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UHlQmz4MZPCYm9BygwyVFf2S1z6UZf0NIZ7PiPTX9pQ=; b=QaYlKwlXixKlNdfMF7QFGqL06c6UL+NvTynCJbvl8SEWJqNtrrVgHkssqsh0lbVky9 82py6GMQKP1hF2q++biV+A9kVBWl3yFKJsLkq7ixbq9ZCdIIG/z5vknJmLe0r47XdOdf 6tOf50iToGFw6x1Vhp9hK559V10t8G4pdZ2/WvF7Xzw5ArglrpgKA2IQ1J8UNzwjSx9e HvViW8lX1phOsgr6ulonq/o1Fz2nFJk59KO6F8KBA6k84Ai+3vA+v0daWDoOlg1RINdt vdxcD5Jq7mms0GqMDJ2a0gjZTLyjdeJLhBYMeZYdnZ3vDyE2VVFXssVo4VGndVAhR599 qJLg== X-Gm-Message-State: AFqh2krv8QHFMHhgFa7ulMNk8RlsPPyBePrxYyoMqAHHK3e0HC8OnrcM yz0ir/gIKG5dtrhyuXn93UkpcCe0ksATHgnJcn1EQw== X-Received: by 2002:a2e:7316:0:b0:283:2205:3ba4 with SMTP id o22-20020a2e7316000000b0028322053ba4mr510837ljc.494.1673369623680; Tue, 10 Jan 2023 08:53:43 -0800 (PST) MIME-Version: 1.0 References: <20230110161831.2625821-1-trix@redhat.com> In-Reply-To: From: Peter Gonda Date: Tue, 10 Jan 2023 09:53:32 -0700 Message-ID: Subject: Re: [PATCH] crypto: initialize error To: Tom Rix 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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-crypto@vger.kernel.org On Tue, Jan 10, 2023 at 9:48 AM Tom Rix wrote: > > > 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. Ack. Not trying to play a blame game =]. Just thought this patch might as well be backported back to anyone using this function. If you are sending another version you can add: Reviewed-by: Peter Gonda > > 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 > >> >