Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1700268pxy; Thu, 29 Apr 2021 12:29:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjjXnT6VrqC/ayoiPbQu/1Z9vRAOlhket70r365A8apyxcxutmBaSy++pIuL0nHoWYin1H X-Received: by 2002:a17:906:6a41:: with SMTP id n1mr68880ejs.401.1619724553670; Thu, 29 Apr 2021 12:29:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619724553; cv=none; d=google.com; s=arc-20160816; b=bJvu20I09H8uFy4V85b6tVrdnRKDYWRjCO/HoD/RkqBhUxa24HRegoeMWkbrwit95L NuKuFsJc2JkiBOXsT0udEAmt0AeOJvLJ4Jb/JwA4BZbKx2DrtJoQz4Ys0Lgi3rsPwtH1 vdeP9P97zulvVO58VMC5TC6T4fJBnj12ze+yajvfhloDPQtRnBj13m1+sTKJqsg7ruI6 jTKMhQHNqCAYhKK0jC+kJZjTyAW4NMuPXpknPIj6995lmQoewSl3pBh1ompyW8jCer/P RcQjBQLCB4AApgzj3FYDkbXnP9GC/UyQGNA2lOJEcwmlgJaCPqlvbbEhrWIQLyK6RudE e/fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=h3cv4urXYSFk97s6YrYJHSj6MAiYXM35h2NCOKlwrv0=; b=vs4Xr/kNn+eBOB6bts9oKAnPljOkw+mqI1JWi8Nsk35lxHYlJKee1U8l8L4nZ5e9rp RUQNjpLwUKYSvm/Brgie6ta07JTw76YbVElkKK+QY0i82YurePT7qEwpq9gpsB/0mYfi mHL4Gc+BLVcQHRV+NPSHJuBa0oB3j7ZiUHQXt/u5kbBYLC4l2Aw/BfzLGgaIis4wwTwe xw5SzK10TS5rlHJl3Js17EcV8wAuZ8bJALViLGr7ie84CbDuDgkOCLdNuvUSSSFRSkBq zeIwd61FVGBorxjeUfUEsGHnCpxpH03XaWQovnsBSdliC6DNaQ2ysEZ+adPBYYvfVN/Q 81aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@benboeckel.net header.s=fm1 header.b=eohsoYKv; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="ucs1s/hh"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h12si885563ejl.147.2021.04.29.12.28.48; Thu, 29 Apr 2021 12:29:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@benboeckel.net header.s=fm1 header.b=eohsoYKv; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="ucs1s/hh"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229617AbhD2TZW (ORCPT + 99 others); Thu, 29 Apr 2021 15:25:22 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:45433 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235623AbhD2TWv (ORCPT ); Thu, 29 Apr 2021 15:22:51 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id A6E895C0093; Thu, 29 Apr 2021 15:22:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 29 Apr 2021 15:22:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=benboeckel.net; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=h3cv4urXYSFk9 7s6YrYJHSj6MAiYXM35h2NCOKlwrv0=; b=eohsoYKvQzbbeIhDknuuEXX9VOE0e QJDIfvp6FoW9zqwDpPOt8lR8wSgvHdzjDpktew7bAtxULwJDmXrLXSAkxY6pwBf6 7iI/chHjVwx9ncWh4s/4Se3iuGzs5G+4gkS8QbRWryLL1hOq+5SdxnQrqXWbLiwt gxDMOhpslwiqubw7Zgp+s3MWbIU0fXG/dF61dO2cI7B2o32suwp0rEvTqYOWl+P7 iur0m5LdGItMhQ838AcZZ+AT3UVTAQGVcFgGmjmi2xAyErkSVzi/GD0MkUXVCWgK JMRNr9Ns94qB1NiZHim347BlqZHoFXv3mX+FJi3/miiK6K17II9NZHiUg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=h3cv4urXYSFk97s6YrYJHSj6MAiYXM35h2NCOKlwrv0=; b=ucs1s/hh UnHw7OVRYnt2bTrUBB3DDQ4iigIgItLyxaqc+otV2imIRzfFWNB+b70BOteCAQzb 9Ekp6SQNw4xC7k8XpbBcj7g0qQNcbGyh7/5lAPgH//ZDSS9eJLqgso5KcgJgQnXX 1c1zaDpid6+0eOqWbzomg6zMh5mKsrTu1G9BrVQ85A6nvWi3jzVw5FDIKWUumbk4 9eM3giPxPbJb2avX9DdTgNjPzSJNDJhFyMPF1HS4gJVqWbBoijbEemh9nGg/d4kn mJ514qM4lZTEAM94F7O7/JDXTeg+8bRgw2JujL1aQG3iZyrooU7gNajZmWcNObKr aJTVeUSPUey2dw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvddvgedgudefkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepuegvnhcu uehovggtkhgvlhcuoehmvgessggvnhgsohgvtghkvghlrdhnvghtqeenucggtffrrghtth gvrhhnpeffkeehlefgteelgefhheekfeeigeffledtkefhveeifeehledtffehkeeuheek heenucfkphepvdegrdduieelrddvtddrvdehheenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehmvgessggvnhgsohgvtghkvghlrdhnvght X-ME-Proxy: Received: from localhost (unknown [24.169.20.255]) by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Apr 2021 15:22:04 -0400 (EDT) From: Ben Boeckel To: keyrings@vger.kernel.org Cc: Ben Boeckel , James Bottomley , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Dan Carpenter Subject: [PATCH v2 1/1] trusted-keys: match tpm_get_ops on all return paths Date: Thu, 29 Apr 2021 15:21:56 -0400 Message-Id: <20210429192156.770145-2-list.lkml.keyrings@me.benboeckel.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210429192156.770145-1-list.lkml.keyrings@me.benboeckel.net> References: <20210429192156.770145-1-list.lkml.keyrings@me.benboeckel.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ben Boeckel The `tpm_get_ops` call at the beginning of the function is not paired with a `tpm_put_ops` on this return path. Fixes: f2219745250f ("security: keys: trusted: use ASN.1 TPM2 key format for the blobs") Reported-by: Dan Carpenter Signed-off-by: Ben Boeckel --- security/keys/trusted-keys/trusted_tpm2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c index 617fabd4d913..0165da386289 100644 --- a/security/keys/trusted-keys/trusted_tpm2.c +++ b/security/keys/trusted-keys/trusted_tpm2.c @@ -336,9 +336,9 @@ int tpm2_seal_trusted(struct tpm_chip *chip, rc = -EPERM; } if (blob_len < 0) - return blob_len; - - payload->blob_len = blob_len; + rc = blob_len; + else + payload->blob_len = blob_len; tpm_put_ops(chip); return rc; -- 2.30.2