Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1825139pxb; Mon, 13 Sep 2021 06:24:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzPv8RsRtCah3Ft7+mFPabsyDvZR0k0M9MNRXzNMNDccBFhZlhahAqL7TzU9VtVlUCVh6F X-Received: by 2002:a92:8743:: with SMTP id d3mr7883835ilm.237.1631539454930; Mon, 13 Sep 2021 06:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631539454; cv=none; d=google.com; s=arc-20160816; b=QWKNe74Gy0rrnuCynCadIuo4EXI4KVFcslTgWD0TaSIRQsL5suIwzqUYyzPl8sU8qQ ZyTwyqRVmr1sFOPKRzh2kB+muEcbAya9RnPaevO7DIoUSKYWu3YWeEy9d7Fh1Xjc/jvO czSWJD8jD/np9f1Vje7imkr1fVXSS/lhGckN3/mq8QD6/WGqIcC4YbbbiNuP2zCSC8iP J5Dytwl1AGvDPV8Aa1Dt5WNcJ7qeBzUjcNSwW47MgQU+6aIUemujnd4xSVxqwq1WKmgA Z3xb+HcZH3saAo4zTWQ0ncEcR5BiuoDzOEzhnxWDczOL14P81qDDiUxhlqegrqkygDWC wEEA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=p3F4v9xO/znryt23sH6DeM+I7SG4W5IcXtIuP/c1aJs=; b=uwOjEzP5u19LnY/D9OanreJGI/nYYF1xIEZNWM+G6sfHYtDgqAYvLWXNlhsHicjuTx BrYU75fKQOSgfP9oS+I4xztd13JWAYu8kK+umeTTdcAeHBXJZ0/aC2AvjhUiypLf/axp 37UfQXjyWG0oh4As7W1wg8aORVn0uoRCwnMXtag/PWPRJdIFfElEAEI7WZb3oWdc9/dy WSofiqI2XIgxvgqZNsHAs8lpaVH2QoYfuBv5da1TzgyfI15T3WQEDEqkjk2SZeeja1mf rAAkoNPQb4/oZ5rvfrmyRcmGJj82Q7Y5KwYteB0i9mLS+Ngz4VmF/ZukvKn32w61ccGq 5hSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MGFqIxxj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m62si5861571ioa.15.2021.09.13.06.24.01; Mon, 13 Sep 2021 06:24:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MGFqIxxj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241259AbhIMNXn (ORCPT + 99 others); Mon, 13 Sep 2021 09:23:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:35288 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240755AbhIMNVd (ORCPT ); Mon, 13 Sep 2021 09:21:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 72A20610D2; Mon, 13 Sep 2021 13:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539218; bh=33QvFHbCTXbaUPpjLD6UmNzkN6ds9LL8q5cT5P2oI5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MGFqIxxj9Www3nTrdUuA00Nkk6lNG8jsKqXHEd4/n1E9ZUq+Ih1K2PJB16UWVhJw0 myGZOfrm9jQkYs2yd6EtdX3qZg/PRCSELA5jxFf7wRS32mv12TMl1jcvw8jhoYpEO1 zYVqTmmwmgpyioP/s5vqDJoDE0VoxMQc/ahPrBI8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Syed Nayyar Waris , William Breathitt Gray , Jonathan Cameron , Sasha Levin Subject: [PATCH 5.4 085/144] counter: 104-quad-8: Return error when invalid mode during ceiling_write Date: Mon, 13 Sep 2021 15:14:26 +0200 Message-Id: <20210913131050.801774754@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131047.974309396@linuxfoundation.org> References: <20210913131047.974309396@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: William Breathitt Gray [ Upstream commit 728246e8f7269ecd35a2c6e6795323e6d8f48db7 ] The 104-QUAD-8 only has two count modes where a ceiling value makes sense: Range Limit and Modulo-N. Outside of these two modes, setting a ceiling value is an invalid operation -- so let's report it as such by returning -EINVAL. Fixes: fc069262261c ("counter: 104-quad-8: Add lock guards - generic interface") Acked-by: Syed Nayyar Waris Signed-off-by: William Breathitt Gray Link: https://lore.kernel.org/r/a2147f022829b66839a1db5530a7fada47856847.1627990337.git.vilhelm.gray@gmail.com Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/counter/104-quad-8.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index 5c23a9a56921..f261a57af1c0 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -1230,12 +1230,13 @@ static ssize_t quad8_count_ceiling_write(struct counter_device *counter, case 1: case 3: quad8_preset_register_set(priv, count->id, ceiling); - break; + mutex_unlock(&priv->lock); + return len; } mutex_unlock(&priv->lock); - return len; + return -EINVAL; } static ssize_t quad8_count_preset_enable_read(struct counter_device *counter, -- 2.30.2