Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp104106ybj; Thu, 19 Sep 2019 11:22:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxS6sUT/+zHCowy3MVYfQulecdiGxT9TQyZnKJUfkjBkSN7MgnHJ85sdYvinuUhXj14LhGk X-Received: by 2002:a05:6402:78b:: with SMTP id d11mr15666574edy.14.1568917323738; Thu, 19 Sep 2019 11:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568917323; cv=none; d=google.com; s=arc-20160816; b=txwMxdnjlkEwnL6opZh9+OcwSR/9JdMGPAHMwXtwHhMCPWZsW4f2WxueOTT6+RS/2k pOM1h74Qjl7lqgKHaPKZpaAPt4b3KSR8i/VaDLduDuvFAfZg1cMjbszJxqchmzF+2wkh DgzR7lyPmuKX2M3cBqnTgLyfz8anb86odZu8wPuYKKszaT7cfGHko3Mm1Z9xdtwXQ4ME UXUzbQ6NPlRwYx6OOp+A+9DZIzpAtp50yUQe6pEAg7n+4016RjEV32j1PlnaGNzxcJHj 5jEyahlVT5bMZ5ToaCUTkT16bj9OVOy1mxjOIIjUqYYQcuVZ185Ks2frCp6JfIK5nFd6 0vVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=I36Yq2VwXBdLTsy979OXOJLPrf5I1O04uwmTwfk7AV0=; b=QtnFFXo2BHBTz0CG70ykfXsBMXuBc35u6Uv8T1T6ZU5YHA6l9y7ZgG902unoNnKoCG iuxcVaiTEjVJiGMVAMl+KjvQmhzUBIwDR7qOnzJrG4nWmOow4cYZ1JOs6HrnpzCQZFJk Fkc0LBGbYpnDsWS/L3d3wLvtw8i+B/NVtCNKNJQxNPVmSjx+iDVEQQSVKa0WMmiKs8kw 3eADUtamZak1t4bF02LphE0id1WzEl7NXrqGOLpGMtPzGdMj5WeWIv/Qwo/RjMcKSaYe 5GAqtVUQCPF5aki4TJDVtcj0qo2mpUQ9cZ1mzf1Ec3dxjm1Rab1tMff1oKMiV5SdBT1C yfog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mBvRSHwQ; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y64si5818334edy.434.2019.09.19.11.21.30; Thu, 19 Sep 2019 11:22:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mBvRSHwQ; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404061AbfISQFE (ORCPT + 99 others); Thu, 19 Sep 2019 12:05:04 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:37739 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404060AbfISQFE (ORCPT ); Thu, 19 Sep 2019 12:05:04 -0400 Received: by mail-io1-f65.google.com with SMTP id b19so9034185iob.4; Thu, 19 Sep 2019 09:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I36Yq2VwXBdLTsy979OXOJLPrf5I1O04uwmTwfk7AV0=; b=mBvRSHwQhaiwSHy+grn5OzxBpH/5Wz/XXFK+oCIKRx1CQ42bj/yMQM7F8U9m20+5vp LsinHDd6aJQaqzp3ENiu6ksW/RNxH/miqtR8eZII+AbtMRWregMnmj6LAEbmw4khObgj YvMgUTZRGBWBvB6y28l7GhnSzcQIvIeZqS6k7cvDm2c76dtMBtSJx0ypJhbo3dqQ1zwQ gCSC3KCpTio4j1lt0TwrAw7XY2UEcTpJsxAKQHd83O5t1W4NsdCsGbQl+ucb3bIk92su UT6imsMlxAiuIwtVjO46s/t2UtOttudfVMD288QdJy8loTF6l98nue+4Sb8kZ6TWkNq1 gn/Q== 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:in-reply-to :references; bh=I36Yq2VwXBdLTsy979OXOJLPrf5I1O04uwmTwfk7AV0=; b=el+Pnfg+Fbje+qxec2DzdDddnHu+vJDzMCKjGP0Fghi2KVKHk1pE6w8BJg2ps4JNmx E1l587E5bLTa7mdOxWR2bIYaZtYFOhcZorOlKaLXeVi+AV7q+8fqGdCxzLpncpM4zy5P /63qfy3KibwqMEttbu670JGr4z+fOubdCUtCZzuNnxBpBn0RuQEwKaGVJvqpz4hPh+7v qiVXONZ//G4wkcjJn6FM0amcczxe+HThcktIEexYlqvqrgGt6VoegggjuaZqvZ2LiW/s ClY+0Xwrh8iQN+evDuyAs0r7/Px5xHDIBjDJyDMMEPsC/r5HQ0dsPkii+McBImXW8kGd 8uNg== X-Gm-Message-State: APjAAAXVos459A0JGI50yZskZIHW+eMx/jBuU2Ccm4BV7yhf9aQeAp7H 2O0CL6HXje2nIEQMUWSG4LOFiAY+eZ8= X-Received: by 2002:a5d:8908:: with SMTP id b8mr918621ion.237.1568909102290; Thu, 19 Sep 2019 09:05:02 -0700 (PDT) Received: from cs-dulles.cs.umn.edu (cs-dulles.cs.umn.edu. [128.101.35.54]) by smtp.googlemail.com with ESMTPSA id g8sm5902449ioc.0.2019.09.19.09.05.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 09:05:01 -0700 (PDT) From: Navid Emamdoost To: ghook@amd.com Cc: emamd001@umn.edu, smccaman@umn.edu, kjlu@umn.edu, Navid Emamdoost , Tom Lendacky , Gary Hook , Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] crypto: ccp - Release all allocated memory if sha type is invalid Date: Thu, 19 Sep 2019 11:04:48 -0500 Message-Id: <20190919160449.4303-1-navid.emamdoost@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <7ffc6a77-f4e3-7db9-4ec6-53d6e01d881d@amd.com> References: <7ffc6a77-f4e3-7db9-4ec6-53d6e01d881d@amd.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Release all allocated memory if sha type is invalid: In ccp_run_sha_cmd, if the type of sha is invalid, the allocated hmac_buf should be released. v2: fix the goto. Signed-off-by: Navid Emamdoost --- drivers/crypto/ccp/ccp-ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c index 9bc3c62157d7..440df9208f8f 100644 --- a/drivers/crypto/ccp/ccp-ops.c +++ b/drivers/crypto/ccp/ccp-ops.c @@ -1782,8 +1782,9 @@ static int ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) LSB_ITEM_SIZE); break; default: + kfree(hmac_buf); ret = -EINVAL; - goto e_ctx; + goto e_data; } memset(&hmac_cmd, 0, sizeof(hmac_cmd)); -- 2.17.1