From patchwork Fri Oct 28 10:25:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9401785 X-Patchwork-Delegate: johannes@sipsolutions.net 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 9523F601C0 for ; Fri, 28 Oct 2016 10:26:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C5CB2A75F for ; Fri, 28 Oct 2016 10:26:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 702072A761; Fri, 28 Oct 2016 10:26:56 +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=unavailable 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 149242A75F for ; Fri, 28 Oct 2016 10:26:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933085AbcJ1K0h (ORCPT ); Fri, 28 Oct 2016 06:26:37 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:57837 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756062AbcJ1K0g (ORCPT ); Fri, 28 Oct 2016 06:26:36 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue103) with ESMTPA (Nemesis) id 0MN62C-1bxtZR0Dn6-006brf; Fri, 28 Oct 2016 12:26:25 +0200 From: Arnd Bergmann To: Johannes Berg Cc: Arnd Bergmann , "David S. Miller" , Jouni Malinen , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] mac80211: fils_aead: fix encrypt error handling Date: Fri, 28 Oct 2016 12:25:53 +0200 Message-Id: <20161028102621.1881878-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 MIME-Version: 1.0 X-Provags-ID: V03:K0:3xRyHmem5lEZfsFQxSChJEZZS3kaCi/UsdND4mR2yZTgKJr2Gd1 UvXdaxURPquy37DWVGAyvH0sdFZZmXQw9WKiUIdRPgchBDnSsdl03wLCMnRtdB48hFY6/2C 7fjLDzYmfQXKw28KL1qZ1oYNlp5FjcfercoU2QxPStHC+Thf9wFWdhpdHpcALZql2B9XDeb Esz+3aA5NV/4YloPlARzQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:IAEYrXkqlS8=:B4NZakm6yljXF740XHNSS3 SJI/2pqeBEXbLSFwqpPjRcZ7BQquEs+H6vOw/IUBaSvHB46ljmC3QY7XhrwCXDSiUluFigIkP B66AsRwLdr7jvp6Z7vvuKalovrq6ryOP8Q+afMISRytzIrfXaoK+C5P+xNHt1UW3E1G5GftbZ gC2e03YB3V0bp/Br73u8B6TAz71J6RuxBqJ9hu40uR8p+7kYFbloOkFupHWRwfmygsLUeNrwL 1I5qnGpW0sUAZJQA+dqGfyckMI9isj/hd5NEP98Ziwnk5b6mZdBuhnq0oBj0/K0g3EkbUkEiU Ux0e2jKuShS+mWx5OY+pTSBqlyKOaMAvpPYLultWbMKw3OkTzpCnIlLIXCIhVt0uRWFDBLNvR hmE9tcZUjvsrJoC2SIlaE7yrchzC9ulkNijkgNl05kVPrzuEj1pPRuBw6yFD5tS6F4BJM7a5D Vvy2KDtFzjEElboIno4YMCrMLfJsMWHrY3paO3Lpn2G5BrYk7mvL4/XsL0IqwpqWMAxXf/RVU BKVcJClRazDLZBGiCtOatZibBhnXYeWrrFPmakVWg5395T+p5X2rLYDACAkcCRlOS38rG6ato vL5X3OiJ5BXreyxQicrnXYO94a3qFD6ekNbqibn8EFUjjz5mWS1Ypw0OuJBF7PP4f4GZz1P/A yiyMvBvRB8ZVu+oSBP6594EO4P66CYTUkYftnO35+Qby7Z0C1HHru/AlaLH19BE4APBAbtAiy 3a2O45zBWHqBW1Ru Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP gcc -Wmaybe-uninitialized reports a bug in aes_siv_encryp: net/mac80211/fils_aead.c: In function ‘aes_siv_encrypt.constprop’: net/mac80211/fils_aead.c:84:26: error: ‘tfm2’ may be used uninitialized in this function [-Werror=maybe-uninitialized] At the time that the memory allocation fails, 'tfm2' has not been allocated, so we should not attempt to free it later, and we can simply return an error. Fixes: 39404feee691 ("mac80211: FILS AEAD protection for station mode association frames") Signed-off-by: Arnd Bergmann --- net/mac80211/fils_aead.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/mac80211/fils_aead.c b/net/mac80211/fils_aead.c index b81b4f2472cf..ecfdd97758a3 100644 --- a/net/mac80211/fils_aead.c +++ b/net/mac80211/fils_aead.c @@ -110,10 +110,8 @@ static int aes_siv_encrypt(const u8 *key, size_t key_len, * overwriting this during AES-CTR. */ tmp = kmemdup(plain, plain_len, GFP_KERNEL); - if (!tmp) { - res = -ENOMEM; - goto fail; - } + if (!tmp) + return -ENOMEM; /* IV for CTR before encrypted data */ memcpy(out, v, AES_BLOCK_SIZE);