Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp46677pxm; Fri, 25 Feb 2022 03:44:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzb2swfXZaWOG3yYjz4y1eEx1zjj3kUYTLhm9ECFvsolth4kouQNPsxwmf//rOkF4GLiocV X-Received: by 2002:a17:906:2695:b0:6ce:f9c:b476 with SMTP id t21-20020a170906269500b006ce0f9cb476mr5897295ejc.235.1645789497799; Fri, 25 Feb 2022 03:44:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645789497; cv=none; d=google.com; s=arc-20160816; b=LD+NVVDpfx7V2dscxP05NRm3dFrwTe+LelYJibgPwmoVP+QwzThZwcRo9qw0H7z6Kt ZPTjDiSu9cl2dT96ZmNe90lTD55QGCk9NcgWj/LMLG/PE/N8qRF6el918F5P1RSWxGmD KeXbUYjprhVKGvZ/CiOoB+T2iQXUb5PN8K4WFVsUKsI55lPra+x3ClgaiuTYMxK3p6R9 FFbZmgToud02IB8Ohck3Cs704LaFnEDInq02Uenn7HT1Ve6CE4pU+N+3PwG30BOP7z+7 TeUHLO4y37a7ZTIHdSF5w4u9clmPxSzcK4tgucxI2fBVGJY3sX0XO5iIq6lkRS37FWlV A9EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Lh99pIe6P2Nw6W6x79cUpkUeEAEuCSeab91A4DY0/c0=; b=e50pANqqfYJZ3AXSF5PEhOUS0nP1m4esf/0aTRYCLtw+utF/f6IYYS6/wu9KdW5jMO 73ulyOHKF4UrwbwNtKgVJQ7EV/LDv5y9Z6zpDxRHHjipqmH450bRlpguXRt4JLtjriMX 9UgqbmWzFt1MUkbYQ9Q4IfcqPdjFkcG5h0GgPJPLSVIi4LrYas7mNLRz/1TjXw6Wdj22 p25se3Yd24vLqJ+858c6OSj9qdK/vlbJqrW4EOzqS36TDOx6gn6GWxirondm9yyntwbh LrCh310i0MFGcOK9Fdd7ed6v7UbTZNeML5+UHb8ilpKEps/iwK/h4iHHFjIKmbOzdwG9 kJvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=LK3K1Xd3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c15-20020a50e3cf000000b00410d3760b2asi1883683edm.200.2022.02.25.03.44.33; Fri, 25 Feb 2022 03:44:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=LK3K1Xd3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239706AbiBYKkn (ORCPT + 99 others); Fri, 25 Feb 2022 05:40:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238106AbiBYKkm (ORCPT ); Fri, 25 Feb 2022 05:40:42 -0500 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C180968F8F for ; Fri, 25 Feb 2022 02:40:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1645785610; x=1677321610; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Lh99pIe6P2Nw6W6x79cUpkUeEAEuCSeab91A4DY0/c0=; b=LK3K1Xd3W/iWU5Zkp0w3GuHPd3o8wjpVgQyD9vuBNCxyXhTcXKt6oorP tCdWF/j8Nakoic/30ywREy3IxwNFBButvxKaKlhDtkECCNIyrWnq4Ae0n uYkIgpK67hvQnTb57ByR1++pyaAIHJJcXbw6XC7zkrfRUPLb1oZjEvBDL M=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-01.qualcomm.com with ESMTP; 25 Feb 2022 02:40:10 -0800 X-QCInternal: smtphost Received: from unknown (HELO nasanex01a.na.qualcomm.com) ([10.52.223.231]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2022 02:40:10 -0800 Received: from hu-rbankapu-blr.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Fri, 25 Feb 2022 02:40:06 -0800 From: Raghu Bankapur To: Vinod Koul , Jaroslav Kysela , "Takashi Iwai" , ierre-Louis Bossart , Mark Brown , "Kai Vehmanen" , Ranjani Sridharan , Takashi Sakamoto , Raghu Bankapur , , Zubin Mithra , CC: Krishna Jha Subject: [PATCH V0 1/1] ALSA: pcm: fix blocking while loop in snd_pcm_update_hw_ptr0() Date: Fri, 25 Feb 2022 16:09:32 +0530 Message-ID: <4d8b1cb4b0db88c3e28207a81403fbf1e4a87bff.1645784757.git.quic_rbankapu@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When period interrupts are disabled, while loop in snd_pcm_update_hw_ptr0() results in the machine locking up if runtime->hw_ptr_buffer_jiffies is 0. Validate runtime->hw_ptr_buffer_jiffies value before while loop to avoid delta check. Signed-off-by: Raghu Bankapur --- sound/core/pcm_lib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index f2090025236b..bb9097f658be 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -352,7 +352,8 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream, * the elapsed time to detect xruns. */ jdelta = curr_jiffies - runtime->hw_ptr_jiffies; - if (jdelta < runtime->hw_ptr_buffer_jiffies / 2) + if ((jdelta < runtime->hw_ptr_buffer_jiffies / 2) || + (runtime->hw_ptr_buffer_jiffies <= 0)) goto no_delta_check; hdelta = jdelta - delta * HZ / runtime->rate; xrun_threshold = runtime->hw_ptr_buffer_jiffies / 2 + 1; -- 2.17.1