public inbox for dm-devel@redhat.com
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Ming-Hung Tsai <mtsai@redhat.com>
Cc: dm-devel@lists.linux.dev
Subject: [bug report] dm cache: fix write hang in passthrough mode
Date: Fri, 10 Apr 2026 13:10:51 +0300	[thread overview]
Message-ID: <adjMq6T5RRjv_uxM@stanley.mountain> (raw)

Hello Ming-Hung Tsai,

Commit 4ca8b8bd952d ("dm cache: fix write hang in passthrough mode")
from Feb 9, 2026 (linux-next), leads to the following Smatch static
checker warning:

	drivers/md/dm-cache-target.c:1527 invalidate_committed()
	error: dereferencing freed memory 'mg' (line 1525)

drivers/md/dm-cache-target.c
    1517 static void invalidate_committed(struct work_struct *ws)
    1518 {
    1519         struct dm_cache_migration *mg = ws_to_mg(ws);
    1520         struct cache *cache = mg->cache;
    1521         struct bio *bio = mg->overwrite_bio;
    1522         struct per_bio_data *pb = get_per_bio_data(bio);
    1523 
    1524         if (mg->k.input)
    1525                 invalidate_complete(mg, false);
                                             ^^
This frees mg.

    1526 
--> 1527         init_continuation(&mg->k, invalidate_completed);
                                    ^^
    1528         remap_to_origin_clear_discard(cache, bio, mg->invalidate_oblock);
                                                           ^^
    1529         dm_hook_bio(&pb->hook_info, bio, overwrite_endio, mg);
                                                                   ^^
But we still dereference it later.

    1530         dm_submit_bio_remap(bio, NULL);
    1531 }

This email is a free service from the Smatch-CI project [smatch.sf.net].

regards,
dan carpenter

             reply	other threads:[~2026-04-10 10:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-10 10:10 Dan Carpenter [this message]
2026-04-10 14:28 ` [bug report] dm cache: fix write hang in passthrough mode Ming Hung Tsai

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=adjMq6T5RRjv_uxM@stanley.mountain \
    --to=error27@gmail.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=mtsai@redhat.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