From: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
To: ZhaoJinming <zhaojinming@uniontech.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
<linux-crypto@vger.kernel.org>, <qat-linux@intel.com>,
<linux-kernel@vger.kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Suman Kumar Chakraborty <suman.kumar.chakraborty@intel.com>,
Laurent M Coquerel <laurent.m.coquerel@intel.com>,
Thorsten Blum <blum@kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH] crypto: qat - free dc_data with kfree() in the error path
Date: Mon, 2 Nov 2026 15:52:07 +0000 [thread overview]
Message-ID: <auixpy8UTqZ5zKNe@gcabiddu-mobl.ger.corp.intel.com> (raw)
In-Reply-To: <20261019-qat-dc-data-kfree-v1-1-b294cb951a77@uniontech.com>
On Mon, Oct 19, 2026 at 01:51:32PM +0800, ZhaoJinming wrote:
> qat_compression_alloc_dc_data() allocates dc_data with kzalloc_node(), but
> its error path releases it with devm_kfree():
>
> dc_data = kzalloc_node(sizeof(*dc_data), GFP_KERNEL,
> dev_to_node(dev));
> ...
> err:
> accel_dev->dc_data = NULL;
> kfree(obuff);
> devm_kfree(dev, dc_data);
>
> devm_kfree() only frees memory that was allocated with devm_kmalloc() and
> registered with the device resource manager. dc_data is a plain kmalloc
> allocation that was never registered, so devres_destroy() does not find it,
> returns -ENOENT and devm_kfree() ends up in WARN_ON() without freeing
> anything. The dc_data structure is leaked.
>
> Commit 4cc871ad0173 ("crypto: qat - use unmanaged allocation for dc_data")
> switched dc_data to unmanaged allocation and replaced the devm_kfree() in
> qat_free_dc_data(), but missed the identical call in the error path of
> qat_compression_alloc_dc_data(). That path is taken when the overflow
> buffer allocation or its DMA mapping fails.
>
> Free dc_data with kfree() here as well, matching the allocation and the
> other release path.
>
> Fixes: 4cc871ad0173 ("crypto: qat - use unmanaged allocation for dc_data")
> Cc: stable@vger.kernel.org
> Signed-off-by: ZhaoJinming <zhaojinming@uniontech.com>
Acked-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Regards,
--
Giovanni
prev parent reply other threads:[~2026-11-02 15:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 5:51 ZhaoJinming
2026-11-02 15:52 ` Giovanni Cabiddu [this message]
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=auixpy8UTqZ5zKNe@gcabiddu-mobl.ger.corp.intel.com \
--to=giovanni.cabiddu@intel.com \
--cc=blum@kernel.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=laurent.m.coquerel@intel.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=qat-linux@intel.com \
--cc=stable@vger.kernel.org \
--cc=suman.kumar.chakraborty@intel.com \
--cc=zhaojinming@uniontech.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
all inboxes | Powered by JetHome®