Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1030061rdb; Wed, 6 Dec 2023 06:57:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8CXW9ozG7yrCYlm+DaUz3CQ+WFcFL45MoIJG93BujsEc4fVSEm1UojjLrBhhrn8irmEll X-Received: by 2002:a05:6a20:7484:b0:18f:97c:b9ef with SMTP id p4-20020a056a20748400b0018f097cb9efmr676601pzd.73.1701874623614; Wed, 06 Dec 2023 06:57:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701874623; cv=none; d=google.com; s=arc-20160816; b=ce/kPcPBTR2uLG7jdy53Jn0BR7TTIPCoWFPQJG0bd/jGYTH9bUZGu1XxA/pLw9x0Vs DDS/AnhGq9t/tz4QW4k3uBqP46rgqIqw13oPp1sbzi3odICa8HZrle6CLveHW3iO2QRo 5YtWJNZwRZVkigYEbKDSE2tnUn5Gt9VlH7Uh0J0oRrHdO+4pz4yMCLlA/iqwF8DmQwXm Y/TeeDDP3Gm7NpWBvhIQxejpesJ2rmq+/KY67hvhYqMeNa65rvf9McxjPx5u3UPC46fF dH8GOkVT6hJ1krwSWEyXXUmLNpq0tuaZJhCmRsOkDCwWvKgTcduGiBeD0DS+ptdraKej NbPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Ucmsp+pjBTlhjv1gBcBSs/5oCUvUo/iNpnLaNAcrn8k=; fh=uxD1fH0jBYbD9YB+6rLAYpQIkSafwlne9c/M60Ooj8c=; b=OXA0vixHF9IBVUK/NSv8Uke4otjqcOILUDybfiFQjHElD0ciDYHTjzUDVs1BY9nsXk PR+FsDLYzRoIfegP8LvlYQjUlqF9indXMO3dJl9/1iIbUYmd2ndR34D+8MJSBq6RPU0p 9R7qZ8/4OE+zuyRCqyCBstSxSmlaveZ9xAUyG2wgfIYsdAh4JDv3qsd+qLlrIO1QkqgC RoKmhBTR0bONuZLhHbeXD88mRlQC+iHEuuMMEPzdcMoKRuXa8ZUECZMMrawZlUFTuA8z YSN5LNB4CUDKqQuIH+z/Zt+sdbffX51DTNATZv+92R+DXfGaXf/HPS5AdDyhLekUdjAE SE2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ML1lc9aC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id 31-20020a630c5f000000b005b90af19430si15214pgm.595.2023.12.06.06.57.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 06:57:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ML1lc9aC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A432380AC44C; Wed, 6 Dec 2023 06:57:00 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379021AbjLFO4i (ORCPT + 99 others); Wed, 6 Dec 2023 09:56:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379015AbjLFO4g (ORCPT ); Wed, 6 Dec 2023 09:56:36 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 239A41BD; Wed, 6 Dec 2023 06:56:43 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40b2a85c99bso7434115e9.0; Wed, 06 Dec 2023 06:56:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701874601; x=1702479401; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Ucmsp+pjBTlhjv1gBcBSs/5oCUvUo/iNpnLaNAcrn8k=; b=ML1lc9aCfZqZ5O9xZS3rUVmzlXxun6Bp4rYsd0FIVy+zueHbD5SyivM/299WQKbNx3 cDUrdmSDgm8hjlgtdvI2Tfn17CcOtJfwEN/mH4n8qfLJUrMb2C6a1P+ntHUY2QDumepn d037sdgDNMO5W/GgB8049/PHurMieJr6apNtMl7o2n9/JMCnDuRu9hFi0jAkYonTBaiF YmFII3nObU/Eqpq4ETmvO5mWXR0qzHBjAZnYjt1nZoGAO6wICUMtnC8QPOY0mENWJDa1 nCim1PDJ2viT3Tzh2fHSchnY1XLNlWOvXzjV9oGPkUIB4Y93QVI3eOOKTQuCHTSyMQNT DYtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701874601; x=1702479401; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ucmsp+pjBTlhjv1gBcBSs/5oCUvUo/iNpnLaNAcrn8k=; b=gq2FT7Mhfevp/al4FhG+/BwNOhA6Fxm8MCfOseLN3rrd7L2OTlkpZwaoJ1iVouNIHY 11cEECXuG6cNWeQDACNThadUwPNnDsANdaoN4L2x/q0Rlb+/5g52+2JpcwGcWjvI1r/8 AUWqaxHId7boSO6tiE3kCrcfrJDrvi4bqgEMOe7ZZaEWaVWb0CcjoPKxtgaMR7HNt2Z7 CfY93IzSOm1OEPzT8c8wh07gXpWJ0Gky+9VB7WPFn74CgHHr1uc+/loj5gbiCjxYlBur XsJaDB0vLf5TLAmItEMGlmw1OBEsa+NXMvnZFzQD5eCXm9/E4UTNtYrnVUeJezI0TQCO pOBg== X-Gm-Message-State: AOJu0YxyGoodmzcTs+4W9gMVmn5qJm7mpNyjd109A6L6xwcAyjQpFFwD fPKY1deqa2mKySOb5tbpW5t4pGjsJr1k1w== X-Received: by 2002:a05:600c:45c5:b0:40b:4ff7:e131 with SMTP id s5-20020a05600c45c500b0040b4ff7e131mr1536006wmo.2.1701874601282; Wed, 06 Dec 2023 06:56:41 -0800 (PST) Received: from ivan-HLYL-WXX9.guest.codethink.co.uk ([167.98.27.226]) by smtp.gmail.com with ESMTPSA id fl8-20020a05600c0b8800b0040b37f1079dsm26261538wmb.29.2023.12.06.06.56.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 06:56:41 -0800 (PST) From: Ivan Orlov To: tiwai@suse.com, perex@perex.cz Cc: Ivan Orlov , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ALSA: pcmtest: stop timer in the hw_free callback Date: Wed, 6 Dec 2023 14:56:37 +0000 Message-Id: <20231206145637.23700-1-ivan.orlov0322@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 06:57:00 -0800 (PST) Stop timer in the 'hw_free' callback instead of the 'close' callback since we want the timer to be stopped before the DMA buffer is released. Otherwise, it could trigger a kernel panic in some circumstances, for instance when the DMA buffer is already released but the timer callback is still running. Signed-off-by: Ivan Orlov --- sound/drivers/pcmtest.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sound/drivers/pcmtest.c b/sound/drivers/pcmtest.c index b59b78a09224..645caf1cc881 100644 --- a/sound/drivers/pcmtest.c +++ b/sound/drivers/pcmtest.c @@ -396,8 +396,6 @@ static int snd_pcmtst_pcm_close(struct snd_pcm_substream *substream) { struct pcmtst_buf_iter *v_iter = substream->runtime->private_data; - timer_shutdown_sync(&v_iter->timer_instance); - v_iter->substream = NULL; playback_capture_test = !v_iter->is_buf_corrupted; kfree(v_iter); return 0; @@ -499,6 +497,11 @@ static int snd_pcmtst_pcm_hw_params(struct snd_pcm_substream *substream, static int snd_pcmtst_pcm_hw_free(struct snd_pcm_substream *substream) { + struct pcmtst_buf_iter *v_iter = substream->runtime->private_data; + + timer_shutdown_sync(&v_iter->timer_instance); + v_iter->substream = NULL; + return 0; } -- 2.34.1