From patchwork Mon Nov 20 22:57:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10067431 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8B03560375 for ; Mon, 20 Nov 2017 22:58:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CA1D21E5A for ; Mon, 20 Nov 2017 22:58:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 712FD2807B; Mon, 20 Nov 2017 22:58:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E69621E5A for ; Mon, 20 Nov 2017 22:58:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751275AbdKTW60 (ORCPT ); Mon, 20 Nov 2017 17:58:26 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:44270 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751158AbdKTW6Z (ORCPT ); Mon, 20 Nov 2017 17:58:25 -0500 Received: by mail-io0-f195.google.com with SMTP id w127so17444244iow.11; Mon, 20 Nov 2017 14:58:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=+H1/kUpdBgmmX6M2Iz9oU6EDko9tpMtWXHm+2oxRDSM=; b=sYEAUbx0xkVdEYJlMTEMnZ3y902CbgRaAa1N5Bf+cEwHMkhhjtWtTGeJSyRCEIYDAJ mSFqxyfl9CLiBPOvEV4vNFoc0mKNnt6n5JwByuOH+ni+0XSCxlOoA7m8KHy5MJE8QscQ nV/ofQZPE4qRJnCJOXjmuLEVVznrR9LWehWuo5CAoR55JNIClT6qg1uJNLMftS+3yT4w cYs9cu1sZYaIwtrl6DtR+wCY2HDBjXmTfZnQtHACN80OCQ2LQA3H4JOiPrjZ7EUcs/EE g1wFcXaA6MWBPhH1hrQDVLl57An2PwYuOYKnt2ElLMLRNTh9DYAi8PY5J4/M+RrYYkAJ DeFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+H1/kUpdBgmmX6M2Iz9oU6EDko9tpMtWXHm+2oxRDSM=; b=Id8au1tUIqm7hMF5GtS0KWY7QGe3KfI2Z0yGYNa7HtvCcny8Kfl1z20yxlFiAW0Dx/ 6xUs62KiqkauNHGM+xhvyTKgF8VgNQ/zv/orra1IRNdf5CfcNnPnOMulpQdRKGG6JMmW UjdSmLMTDGjUtwMZnDUql6oJQunf1qO1jIB6ZUIs0z77YOfwmyRNab+uUYqBYtohjIks 1aw8/nCnIrDNnjO3LSOw8axAWkmJKsqtg9lXfk07TNdHOPNzqXUtLAK8w0+cQ3Wry4Rw JWC9AUxkO5uO+vaSE+oNjWSlwD4hfpnD7KQB87O8DDAuXqJi7cauVv+PC8tQOjW10lNM t+Nw== X-Gm-Message-State: AJaThX4O5k0c113ZiFpRHaak5D9a+2eZCVdX4jxQm9I49NA3J0sbRAuX /8ep2f6JPC81xU07TIdm19FRbab0 X-Google-Smtp-Source: AGs4zMb+hm+TolVYUnQckYjeKgeA/T+DWt7TdFfNDClo3uhk0XxfCwxJOjMB+GBOMCzeHffF2m1uzw== X-Received: by 10.107.150.4 with SMTP id y4mr17158190iod.259.1511218704006; Mon, 20 Nov 2017 14:58:24 -0800 (PST) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.66.175.88]) by smtp.gmail.com with ESMTPSA id k2sm4914797iok.43.2017.11.20.14.58.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Nov 2017 14:58:23 -0800 (PST) From: Eric Biggers To: keyrings@vger.kernel.org, David Howells Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Biggers Subject: [PATCH] KEYS: remove unnecessary get/put of explicit dest_keyring Date: Mon, 20 Nov 2017 14:57:57 -0800 Message-Id: <20171120225757.96498-1-ebiggers3@gmail.com> X-Mailer: git-send-email 2.15.0.448.gf294e3d99a-goog Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers In request_key_and_link(), in the case where the dest_keyring was explicitly specified, there is no need to get another reference to dest_keyring before calling key_link(), then drop it afterwards. This is because by definition, we already have a reference to dest_keyring. This change is useful because we'll be making construct_get_dest_keyring() able to return an error code, and we don't want to have to handle that error here for no reason. Signed-off-by: Eric Biggers --- security/keys/request_key.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/security/keys/request_key.c b/security/keys/request_key.c index e8036cd0ad54..c6880af8b411 100644 --- a/security/keys/request_key.c +++ b/security/keys/request_key.c @@ -546,9 +546,7 @@ struct key *request_key_and_link(struct key_type *type, if (!IS_ERR(key_ref)) { key = key_ref_to_ptr(key_ref); if (dest_keyring) { - construct_get_dest_keyring(&dest_keyring); ret = key_link(dest_keyring, key); - key_put(dest_keyring); if (ret < 0) { key_put(key); key = ERR_PTR(ret);