Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2517116imm; Mon, 24 Sep 2018 05:48:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV62BVQPmj6nDCZMpCb47sky755b0twSkIrw9XX4GsBmRJg35pm7UnYcj0PluFxWRF1jjddOK X-Received: by 2002:a17:902:18a:: with SMTP id b10-v6mr10637442plb.62.1537793297483; Mon, 24 Sep 2018 05:48:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537793297; cv=none; d=google.com; s=arc-20160816; b=XXfpnU93Nfs1a1uBa7ikTdACwBmEHKDBhexV0lgg1bzcVvk3nACpvQ+3K7ynKD1G5t AM5+X5hahSHOEuzsf0kXazfycN13SNrz3E2O78Aq2EJFMWG+0+jp45zPfsHREivoK4N5 c+y1FCHvtGJJ2YKC4+HFQP18a3OfQASTs7FPGRqXmMTOaPrY5WYrj91L5MzEpy3Scz6K vsrILt/ydzvfHZ/lO3viq0QmxZn+3grm0h0K78OvdUD4Cm1NW3n/pyXyhFDc33T/epOs Ev7WAxfpwwMdu2L6u7qTqqa9bnPewAj12+8S9FpaDuhvfVgmETiY1g+rcERwgLyC6MxA Zqjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=GXX+W1sM4+Ud3lgEoFca3/h8apiX6S+qW5wWxEU6Bd8=; b=yjoXz5YeG3oWRGVR9xiloPajdWt4V5ahtsZXgNHKKJoILXXWd663biTyF0HP5xGpJh S58IsEhMopf7bjWuhOJaLnysGC1EHQeT7JKqX7qmLkizAoJKXFTkeZGXszwVcXr1tuOY kF9FQepwRdpzPsDvMCJT8s5zoW6td6sH1nMWByVM3S3tkUdkfJrKNIPrQzZ8/PUa4M0q Am5copw7VSR1JWROFUPh2lk+56xQFzW9nSlAmvuc4bCyGpDZHfUPkRZzMGzbqUSEI6E9 VF1P2F1WVi31rL2NoCueHXT1LRqiP7z/QtrXNHHRRSo+9618kvpCsnnjzXwX6NPWVDgN mWTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 68-v6si35850057pff.55.2018.09.24.05.48.02; Mon, 24 Sep 2018 05:48:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389392AbeIXSsD (ORCPT + 99 others); Mon, 24 Sep 2018 14:48:03 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59864 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730401AbeIXSsC (ORCPT ); Mon, 24 Sep 2018 14:48:02 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D0593109A; Mon, 24 Sep 2018 12:46:02 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Timo Wischer , Takashi Iwai , Sasha Levin Subject: [PATCH 4.18 213/235] ALSA: pcm: Fix snd_interval_refine first/last with open min/max Date: Mon, 24 Sep 2018 13:53:19 +0200 Message-Id: <20180924113124.983012170@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Timo Wischer [ Upstream commit ff2d6acdf6f13d9f8fdcd890844c6d7535ac1f10 ] Without this commit the following intervals [x y), (x y) were be replaced to (y-1 y) by snd_interval_refine_last(). This was also done if y-1 is part of the previous interval. With this changes it will be replaced with [y-1 y) in case of y-1 is part of the previous interval. A similar behavior will be used for snd_interval_refine_first(). This commit adapts the changes for alsa-lib of commit 9bb985c ("pcm: snd_interval_refine_first/last: exclude value only if also excluded before") Signed-off-by: Timo Wischer Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- sound/core/pcm_lib.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -626,27 +626,33 @@ EXPORT_SYMBOL(snd_interval_refine); static int snd_interval_refine_first(struct snd_interval *i) { + const unsigned int last_max = i->max; + if (snd_BUG_ON(snd_interval_empty(i))) return -EINVAL; if (snd_interval_single(i)) return 0; i->max = i->min; - i->openmax = i->openmin; - if (i->openmax) + if (i->openmin) i->max++; + /* only exclude max value if also excluded before refine */ + i->openmax = (i->openmax && i->max >= last_max); return 1; } static int snd_interval_refine_last(struct snd_interval *i) { + const unsigned int last_min = i->min; + if (snd_BUG_ON(snd_interval_empty(i))) return -EINVAL; if (snd_interval_single(i)) return 0; i->min = i->max; - i->openmin = i->openmax; - if (i->openmin) + if (i->openmax) i->min--; + /* only exclude min value if also excluded before refine */ + i->openmin = (i->openmin && i->min <= last_min); return 1; }