Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1043537rdb; Wed, 6 Dec 2023 07:13:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWdKUC+N31aKm4DyTF2aA2CRi/TX+OXdt4ZLOpBzHhDt78JEwuGsxMLPnSfSAUYG2B2rXr X-Received: by 2002:a05:6a20:3d85:b0:18c:af15:7e73 with SMTP id s5-20020a056a203d8500b0018caf157e73mr921590pzi.48.1701875607232; Wed, 06 Dec 2023 07:13:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875607; cv=none; d=google.com; s=arc-20160816; b=CeFZZDV4h5XzV3EKFGn3FspXRRmkDaoX/lJ5qUSDS64MUXkUXUAzyQMNrr1jLGAOen bVclhmg2zjjcVCGfXQxp7N2ym9VV0KdO7uC92Qg3MgZP1AhbSJhpiW7Ore0T3Box1VGa SmEnMhVqJmysdL6z5kWMY4ovc9q74wVqFhBcEw7t77RIKFKSc01UZrDyU1z4WY3ZApQa MplOGc/+42B8WicxRzVnRBx5s2LyHJD918UpqOl11oY28+l92gSM29nZkkHEwMB55dSw osji8Vslc24kdRB2JxnsJropgcKQMtHie1wvNsV8kX/tYO5v3kSapxTw8LMJ+Ced/Ok9 D12w== 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=Exeor/DNWicuvK3cbDYRlFe90J3H0CF8DFmA9Uf4TNE=; fh=uxD1fH0jBYbD9YB+6rLAYpQIkSafwlne9c/M60Ooj8c=; b=uNk6FZlPX/jKc616AAND04UU2P5UcaIUS7MPt4HPG9/hwXKHN45qInLER/cMVGbrSU sug85rh2couJTjq+C9IVeZLrUvbTwRbpN2dg+D+EMkVK7ToH9Tvm9zHh+LqFr8q3puoF u1U609sXPsyUv0+47vI7ewpBt0VhZoO7CP0mgRBLT/qrhAVBffMlCm3wZer/E5nhLp3U GnvNdna5iHyskxSYkPZat2BhQIv/Z6v7sxbicfoOxbjQ+MQvHn3g/02IRPCQUrs2RM9c yqjBVGr++woPufIfLPh696UryZHO4KQ40z3oypHJUJtr6GwJsd+CcTbo2RiuvLbeHXED G/dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ViovDYPD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id t9-20020a656089000000b005c659bf1c70si51387pgu.206.2023.12.06.07.13.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:13:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ViovDYPD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id A0BBF80930DB; Wed, 6 Dec 2023 07:11:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379244AbjLFPK6 (ORCPT + 99 others); Wed, 6 Dec 2023 10:10:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379171AbjLFPKp (ORCPT ); Wed, 6 Dec 2023 10:10:45 -0500 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91AACD67; Wed, 6 Dec 2023 07:10:51 -0800 (PST) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-50bf5398755so819608e87.0; Wed, 06 Dec 2023 07:10:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701875450; x=1702480250; 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=Exeor/DNWicuvK3cbDYRlFe90J3H0CF8DFmA9Uf4TNE=; b=ViovDYPD1emESdOx+5t7DNwLzU72R0UQbqP5XMXC6Z+fHyy/wNWo3GjdYyUH6rrzGD NlKsHvYXW3QB6PniMFRdTQEYwq2vTJIyMFU33TsFGUcdXE6gO4CYtp09/EubVl/MQUxO OMu33m2Mn1zc9t3ydfho+Ym5Je1NYTgS6xssNM+nKjiD+dwxTLG1d4osEtVT4u5Yt7lq zlBvMj5ypVDxlWl4k1fKXAhqtcZ0QOp+dT42yHQoWD2392Ej2lof0FqzC1Qoh4igZ8QK WYa2h+5YsyVzKGpaeta1CgSYuoyW6L3PU+SnAvfMxlcnMGzctb7ruuHzaY8GZwftEPik M+AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701875450; x=1702480250; 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=Exeor/DNWicuvK3cbDYRlFe90J3H0CF8DFmA9Uf4TNE=; b=bKkYtAZLT/MY9loU+44KSBVXzmSW/tT78UiMgldgnkL3LEzFRFqv1KEVOdxRjU4Wmu eu4upAYh7+tEpXm7AnsMJepN9vQ+LVpig7t/BBs4xn4idiQnQu2Q1dVtMqEiprqKDiGa IIj0QM0z0Wzw124uAdc1TyZsp/dgC5Yhfrj7ZcTHGvttNGD2+mt8AgImZHg+HjnkSrxX e1D/O50eTk5ex5U5t90nJsewL4X3Esn4biaWNeUU9/SQ/NrCxXzs5UNaRoUcGsH8rs2u TfC+lmwkuaTu/qEthwr9R88wU3l0dY4h3Ib1S4Hu0AVZ1FZAh76RqysmZcyz6HgdSDu7 QYUg== X-Gm-Message-State: AOJu0Yz+cx8vkIAbBQZ2wOduU8SauGfPRrSfbx42Vk0sAypBclp2DZxU jX72O6FfNBtl0FGU66jYdQi8iSwTyZ1V3g== X-Received: by 2002:a05:6512:ac2:b0:509:4962:6fe with SMTP id n2-20020a0565120ac200b00509496206femr1552238lfu.1.1701875449455; Wed, 06 Dec 2023 07:10:49 -0800 (PST) Received: from ivan-HLYL-WXX9.guest.codethink.co.uk ([167.98.27.226]) by smtp.gmail.com with ESMTPSA id p11-20020a05600c468b00b0040b561924bbsm23738486wmo.21.2023.12.06.07.10.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:10:49 -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 v2] ALSA: pcmtest: stop timer in the hw_free callback Date: Wed, 6 Dec 2023 15:10:46 +0000 Message-Id: <20231206151046.25773-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 howler.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 (howler.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:11:20 -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 --- V1 -> V2: - Remove useless NULLing of v_iter->substream. It will be released in 'close' callback. sound/drivers/pcmtest.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/drivers/pcmtest.c b/sound/drivers/pcmtest.c index b59b78a09224..8a78fa56106f 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,10 @@ 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); + return 0; } -- 2.34.1