From patchwork Sun Jun 23 19:18:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Rientjes X-Patchwork-Id: 11011919 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D1D5E112C for ; Sun, 23 Jun 2019 19:18:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC70028A89 for ; Sun, 23 Jun 2019 19:18:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD6F928ABA; Sun, 23 Jun 2019 19:18:48 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 5790628A89 for ; Sun, 23 Jun 2019 19:18:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726289AbfFWTSr (ORCPT ); Sun, 23 Jun 2019 15:18:47 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:45132 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726119AbfFWTSr (ORCPT ); Sun, 23 Jun 2019 15:18:47 -0400 Received: by mail-pf1-f194.google.com with SMTP id r1so6202137pfq.12 for ; Sun, 23 Jun 2019 12:18:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=f9qXptgylHIAEQXQTAuBnq2RBq3dvQEaePaTzKc6t5o=; b=KQ4j5ZKmjcMZt3yJiy9ufK2L4dMLjg1mXx6wX7BtxENgmv9ZDdkCUV1I9bSu4M/8ik 9mnLUHwkqwm3G/cVj/1SUXEbG0XWNrmOyC9l3b1H5cGyncPyiwkUg8tQEEhMFfjLuh82 jy/is46Fjz/qQixn41IByRhOMz3Bmgb7W3xiLSejYdSh7MJ9y3BA67/GYoDe5eBU1slV n/Jr4PdFwyPoc7lqMcMQAyvwzCrhO52Qea7CXiW0tX1Sq4jnVyZ5bMVlHb9NAW8TiEVg gGwAukMIfG9ytZ1KpjlWijFFoU70ZTUa9rVf8APnhmyMsv0YX5SriHHYNsgpp+4xCAYp 1NlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :mime-version; bh=f9qXptgylHIAEQXQTAuBnq2RBq3dvQEaePaTzKc6t5o=; b=UOnMOaJS+SCB8TsdUtaBJOYKCeWNyaJGonZys1XsYX90tyjM55K7IchwFgvN8HAOLx bQb76ec+h89o/bypCt6zQha+P5YxtupN8t2ZYzv2xZ9gFD9JKJSTJFcHVZVwFxj46tW2 88YmsviSZqDyJLij04TyJJc7KtaBslfBqlj+ezwjQm3vls7agrT3tL8Fzd7kUGyeQEhH 5IDjAnv/RNdkNfkHA/1j3cdi4hGW4nrhGNzTMQDAgZVKEBeUBMaXIQKl0F24ptL4Zn5T a3gBAJJ0JKJpw+iD2rk1Gm3ty23Ub3Z9iPWSMshzSwp12HoENFDBARGvzBJfnfMxtCFN 6qxg== X-Gm-Message-State: APjAAAU58Tof/QFi3DHexGX5xzPfYNG9fn8Jr0ZOllZJZRephGMrc3zr SjgNBydNZA0weMHVECoLXbFxqA== X-Google-Smtp-Source: APXvYqy6th0fKsgTaL4WunOqvuhGKOUKqQYaQw7eAE0Dqj3MtmkeNpMhyAK2c4KAlL1lXEfEpOBw9g== X-Received: by 2002:a63:4419:: with SMTP id r25mr30247484pga.247.1561317525806; Sun, 23 Jun 2019 12:18:45 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id f88sm9808002pjg.5.2019.06.23.12.18.44 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 12:18:44 -0700 (PDT) Date: Sun, 23 Jun 2019 12:18:44 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Tom Lendacky , Gary Hook , Herbert Xu cc: Brijesh Singh , Cfir Cohen , linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Subject: [patch] crypto: ccp - Free ccp if initialization fails Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If ccp_dev_init() fails, kfree() the allocated ccp since it will otherwise be leaked. Fixes: 720419f01832 ("crypto: ccp - Introduce the AMD Secure Processor device") Reported-by: Cfir Cohen Signed-off-by: David Rientjes Nacked-By: Gary R Hook --- drivers/crypto/ccp/ccp-dev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c --- a/drivers/crypto/ccp/ccp-dev.c +++ b/drivers/crypto/ccp/ccp-dev.c @@ -609,6 +609,7 @@ int ccp_dev_init(struct sp_device *sp) e_err: sp->ccp_data = NULL; + kfree(ccp); dev_notice(dev, "ccp initialization failed\n");