The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@kernel.org>,
	Mikulas Patocka <mpatocka@redhat.com>,
	Benjamin Marzinski <bmarzins@redhat.com>,
	Linlin Zhang <linlin.zhang@oss.qualcomm.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	dm-devel@lists.linux.dev
Subject: Re: [PATCH] dm-inlinecrypt: Fix an error handling path in inlinecrypt_ctr()
Date: Sat, 20 Jun 2026 14:23:19 -0700	[thread overview]
Message-ID: <20260620212319.GA1702@quark> (raw)
In-Reply-To: <2b6e6b71e66fbe90c75791669a9e16a36b48f7f6.1781983971.git.christophe.jaillet@wanadoo.fr>

On Sat, Jun 20, 2026 at 09:33:03PM +0200, Christophe JAILLET wrote:
> All error handling paths, except but this one, branch to the 'bad' label in
> the error handling path.
> 
> If not done, there is a memory leak and some sensitive data may be kept
> around.
> 
> So, fix this error path and also do the needed clean-up.
> 
> Fixes: e7f57d2c47e2 ("dm-inlinecrypt: add target for inline block device encryption")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested only
> ---
>  drivers/md/dm-inlinecrypt.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/md/dm-inlinecrypt.c b/drivers/md/dm-inlinecrypt.c
> index be1b4aa8f28b..bb4ded4757d1 100644
> --- a/drivers/md/dm-inlinecrypt.c
> +++ b/drivers/md/dm-inlinecrypt.c
> @@ -347,7 +347,8 @@ static int inlinecrypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
>  	err = get_key_size(&argv[1]);
>  	if (err < 0) {
>  		ti->error = "Cannot parse key size";
> -		return -EINVAL;
> +		err = -EINVAL;
> +		goto bad;
>  	}
>  	ctx->key_size = err;

Reviewed-by: Eric Biggers <ebiggers@kernel.org>

The missing 'goto' below could use a patch too:

	if (ctx->iv_offset & ((ctx->sector_size >> SECTOR_SHIFT) - 1)) {
		ti->error = "Wrong alignment of iv_offset sector";
		err = -EINVAL;
	}

      reply	other threads:[~2026-06-20 21:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-20 19:33 [PATCH] dm-inlinecrypt: Fix an error handling path in inlinecrypt_ctr() Christophe JAILLET
2026-06-20 21:23 ` Eric Biggers [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=20260620212319.GA1702@quark \
    --to=ebiggers@kernel.org \
    --cc=agk@redhat.com \
    --cc=bmarzins@redhat.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dm-devel@lists.linux.dev \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linlin.zhang@oss.qualcomm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@kernel.org \
    /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