From patchwork Sun May 21 11:05:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9738989 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 2ADB260326 for ; Sun, 21 May 2017 11:06:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C245286CD for ; Sun, 21 May 2017 11:06:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F4B3286D2; Sun, 21 May 2017 11:06:16 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 AAD44286CD for ; Sun, 21 May 2017 11:06:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751198AbdEULFz (ORCPT ); Sun, 21 May 2017 07:05:55 -0400 Received: from mout.web.de ([212.227.17.12]:49185 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750999AbdEULFy (ORCPT ); Sun, 21 May 2017 07:05:54 -0400 Received: from [192.168.1.3] ([78.48.227.118]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Md4l4-1dUTnF1ygk-00IFlg; Sun, 21 May 2017 13:05:39 +0200 To: keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, David Howells , David Safford , James Morris , Mimi Zohar , "Serge E. Hallyn" Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Subject: [PATCH] KEYS: Delete an error message for a failed memory allocation in get_derived_key() Message-ID: <12d1c638-5cf6-71be-b1b7-486b8663e022@users.sourceforge.net> Date: Sun, 21 May 2017 13:05:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:WCk/f0ClvAWUBg2uTZVUrhY8mQnx0oN3u1wz4dHS2+yXzM5dfDg e7aVq1AC76aoGT05le9dH+UzmPyU57nrAidiFBLtA9ZgAex3bGm7q/gcY2XfDFLvMC3o1si GV1v9gXI+3vg9nGx3lLdAPg+RkhTOsPNDBfAf9Jsl0owW037TD8tKeXhjRH5L8Y3z9VFd2K SFsYzIEFxl0XAmxCPUJjw== X-UI-Out-Filterresults: notjunk:1; V01:K0:xY3phfV4J1U=:lpIQ7Xd+a0gYMvOBiTfMtu GFre+D44akJjZr3z7Wzc5a2KWg0d458XytPtVb584AcwMJ2lv3l6Ns8mGE5E/g+A9EpPg4go5 IK2lC/MZYS76Sd6XCutGGFo9usqaQU+0ZrAtz/BMvd5xsacSX6F1kN8WRv37/wOkZ0U6LCWS/ w2v7tJjvVxr1QnSwLKJqITklTUb3jDskhKef1WfAr98p8Cn79up1Vn3dUxHkrMnDN+X8whMd5 xkdQcHYGR9gigFzHsI7dY5UOH8Ylu/L62jkwgmhOaItxaam9VYisPavalzjQcSXVAh89AvSkP 6pLoHIWMf1h3BRccHP5UGgdk9ODWl9U/fdx3k35L3iv/e20hiwrPn226eVVW05qRPddOsc870 fq4FRP5AJsDaqqa33yXxvNGL1rnDZlngrzKlNn+4rdrgmTHsIoAuYQtlfLg7ZTC5zGBtQO1Qs 271yKPfb6d1eBpuo6sKsBSCuDwPUwKJv+Naewk2/M/08OlQV3Tym4QzrgEfGA98CLv5VwQveV wJaR9WR9rdKkGaUw9Xqfy7vCkmym9qKpmZfGR3cleEXpGf2WLjW8DD8g6nf3RYyZh2txik/tE z+6ldE9oZJna2gOrMwZM50jvKqn5m7qSOHvF4rBDZXjXHrEvXa4DqrbFryL15VFzFfuJn/O+z 7SBJRNFg0ItAWv1l8S8n/aVJTPnGZDpMkKzXAGmSs4kyoXOjhigZMSm/81lx1FUHu8UlwyXGH A9XVypmc5i8aqOYOnf+XOTNcchQ7h8SHAc6rEwee4Vvg1jEt+DAOBPwOz3WH1MkwU3eV1BCeL TQa+cCf Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 21 May 2017 11:23:55 +0200 Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring --- security/keys/encrypted-keys/encrypted.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/security/keys/encrypted-keys/encrypted.c b/security/keys/encrypted-keys/encrypted.c index 1ca895e7e56a..ad57914452c1 100644 --- a/security/keys/encrypted-keys/encrypted.c +++ b/security/keys/encrypted-keys/encrypted.c @@ -385,10 +385,9 @@ static int get_derived_key(u8 *derived_key, enum derived_key_type key_type, derived_buf_len = HASH_SIZE; derived_buf = kzalloc(derived_buf_len, GFP_KERNEL); - if (!derived_buf) { - pr_err("encrypted_key: out of memory\n"); + if (!derived_buf) return -ENOMEM; - } + if (key_type) strcpy(derived_buf, "AUTH_KEY"); else