public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
To: Quentin Lambert <lambert.quentin@gmail.com>
Cc: Salvatore Benedetto <salvatore.benedetto@intel.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	qat-linux@intel.com, linux-crypto@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	giovanni.cabiddu@gmail.com, giovanni.cabiddu@intel.com
Subject: Re: [PATCH v2 2/2] crypto: qat - fix resource release omissions
Date: Tue, 6 Sep 2016 11:18:51 +0100	[thread overview]
Message-ID: <20160906101851.GA27032@sivswdev01.ir.intel.com> (raw)
In-Reply-To: <20160902144753.31334-3-lambert.quentin@gmail.com>

Hi Lambert,

On Fri, Sep 02, 2016 at 04:47:53PM +0200, Quentin Lambert wrote:
> In certain cases qat_uclo_parse_uof_obj used to return with an error code
> before releasing all resources. This patch add a jump to the appropriate label
> ensuring that the resources are properly released before returning.
> 
> This issue was found with Hector.
Thanks for the patches. This can be easily fixed by moving the kcalloc after 
the compatibility check function. What do you think?

---8<---
Subject: [PATCH] crypto: qat - fix leak on error path

Fix a memory leak in an error path in uc loader.

Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
---
 drivers/crypto/qat/qat_common/qat_uclo.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/qat_uclo.c b/drivers/crypto/qat/qat_common/qat_uclo.c
index 9b961b3..e2454d9 100644
--- a/drivers/crypto/qat/qat_common/qat_uclo.c
+++ b/drivers/crypto/qat/qat_common/qat_uclo.c
@@ -967,10 +967,6 @@ static int qat_uclo_parse_uof_obj(struct icp_qat_fw_loader_handle *handle)
 	struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
 	unsigned int ae;
 
-	obj_handle->uword_buf = kcalloc(UWORD_CPYBUF_SIZE, sizeof(uint64_t),
-					GFP_KERNEL);
-	if (!obj_handle->uword_buf)
-		return -ENOMEM;
 	obj_handle->encap_uof_obj.beg_uof = obj_handle->obj_hdr->file_buff;
 	obj_handle->encap_uof_obj.obj_hdr = (struct icp_qat_uof_objhdr *)
 					     obj_handle->obj_hdr->file_buff;
@@ -982,6 +978,10 @@ static int qat_uclo_parse_uof_obj(struct icp_qat_fw_loader_handle *handle)
 		pr_err("QAT: UOF incompatible\n");
 		return -EINVAL;
 	}
+	obj_handle->uword_buf = kcalloc(UWORD_CPYBUF_SIZE, sizeof(uint64_t),
+					GFP_KERNEL);
+	if (!obj_handle->uword_buf)
+		return -ENOMEM;
 	obj_handle->ustore_phy_size = ICP_QAT_UCLO_MAX_USTORE;
 	if (!obj_handle->obj_hdr->file_buff ||
 	    !qat_uclo_map_str_table(obj_handle->obj_hdr, ICP_QAT_UOF_STRT,
-- 

  reply	other threads:[~2016-09-06 10:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-02 14:37 [PATCH 0/2] add omitted release in qat_common Quentin Lambert
2016-09-02 14:37 ` [PATCH 1/2] crypto: qat - introduces a variable to handle error codes Quentin Lambert
2016-09-02 14:37 ` [PATCH 2/2] crypto: qat - fix resource release omissions Quentin Lambert
2016-09-02 14:43 ` [PATCH 0/2][RESEND] add omitted release in qat_common Quentin Lambert
2016-09-02 14:43   ` [PATCH 1/2][RESEND] crypto: qat - introduces a variable to handle error codes Quentin Lambert
2016-09-02 14:43   ` [PATCH 2/2] crypto: qat - fix resource release omissions Quentin Lambert
2016-09-02 14:47   ` [PATCH v2 0/2] add omitted release in qat_common Quentin Lambert
2016-09-02 14:47     ` [PATCH v2 1/2] crypto: qat - introduces a variable to handle error codes Quentin Lambert
2016-09-02 14:47     ` [PATCH v2 2/2] crypto: qat - fix resource release omissions Quentin Lambert
2016-09-06 10:18       ` Giovanni Cabiddu [this message]
2016-09-13 12:40         ` Herbert Xu
2016-09-13 12:56           ` Quentin Lambert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160906101851.GA27032@sivswdev01.ir.intel.com \
    --to=giovanni.cabiddu@intel.com \
    --cc=davem@davemloft.net \
    --cc=giovanni.cabiddu@gmail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lambert.quentin@gmail.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qat-linux@intel.com \
    --cc=salvatore.benedetto@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox