mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: syzbot <syzbot+73582d08864d8268b6fd@syzkaller.appspotmail.com>
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [sound?] INFO: task hung in snd_card_free
Date: Sun,  3 Nov 2024 09:28:45 +0800	[thread overview]
Message-ID: <20241103012845.3066-1-hdanton@sina.com> (raw)
In-Reply-To: <6726bf35.050a0220.35b515.018b.GAE@google.com>

On Sat, 02 Nov 2024 17:09:25 -0700
> syzbot found the following issue on:
> 
> HEAD commit:    e42b1a9a2557 Merge tag 'spi-fix-v6.12-rc5' of git://git.ke..
> git tree:       upstream
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1274ca30580000

#syz test

--- x/sound/core/init.c
+++ y/sound/core/init.c
@@ -577,9 +577,13 @@ void snd_card_disconnect_sync(struct snd
 }
 EXPORT_SYMBOL_GPL(snd_card_disconnect_sync);
 
+static DEFINE_SPINLOCK(release_sl);
+
 static int snd_card_do_free(struct snd_card *card)
 {
+	spin_lock(&release_sl);
 	card->releasing = true;
+	spin_unlock(&release_sl);
 #if IS_ENABLED(CONFIG_SND_MIXER_OSS)
 	if (snd_mixer_oss_notify_callback)
 		snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_FREE);
@@ -591,8 +595,10 @@ static int snd_card_do_free(struct snd_c
 		dev_warn(card->dev, "unable to free card info\n");
 		/* Not fatal error */
 	}
+	spin_lock(&release_sl);
 	if (card->release_completion)
 		complete(card->release_completion);
+	spin_unlock(&release_sl);
 	if (!card->managed)
 		kfree(card);
 	return 0;
@@ -637,16 +643,20 @@ void snd_card_free(struct snd_card *card
 {
 	DECLARE_COMPLETION_ONSTACK(released);
 
+	spin_lock(&release_sl);
 	/* The call of snd_card_free() is allowed from various code paths;
 	 * a manual call from the driver and the call via devres_free, and
 	 * we need to avoid double-free. Moreover, the release via devres
 	 * may call snd_card_free() twice due to its nature, we need to have
 	 * the check here at the beginning.
 	 */
-	if (card->releasing)
+	if (card->releasing) {
+		spin_unlock(&release_sl);
 		return;
+	}
 
 	card->release_completion = &released;
+	spin_unlock(&release_sl);
 	snd_card_free_when_closed(card);
 
 	/* wait, until all devices are ready for the free operation */
--

  reply	other threads:[~2024-11-03  1:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-03  0:09 syzbot
2024-11-03  1:28 ` Hillf Danton [this message]
2024-11-03  1:49   ` syzbot
2024-11-05  2:37 ` Edward Adam Davis
2024-11-05  3:12   ` syzbot
2024-11-05  3:59 ` Edward Adam Davis
2024-11-05  4:18   ` syzbot
2024-11-05  5:03 ` Edward Adam Davis
2024-11-05  5:23   ` syzbot
2024-11-05  6:57 ` Edward Adam Davis
2024-11-05  7:31   ` syzbot
2024-11-05  8:54 ` Edward Adam Davis
2024-11-05 10:52   ` syzbot
2024-11-05 11:22 ` Edward Adam Davis
2024-11-05 21:06   ` syzbot
2024-11-06  1:37 ` Edward Adam Davis
2024-11-06  2:02   ` syzbot
2024-11-06  2:15 ` [PATCH] usb: fix a " Edward Adam Davis
2024-11-12 16:04   ` Takashi Iwai
2024-11-13  1:48     ` Edward Adam Davis
2024-11-13  6:48       ` Takashi Iwai

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=20241103012845.3066-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+73582d08864d8268b6fd@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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®