Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp67867pxb; Mon, 13 Sep 2021 13:08:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNN7akBUjJcJKWZ6StvIKcQO6L6PIJJBi8CxMD1ZNXEF5TIn0FOqbyMxnv2HbTtbWgHQt5 X-Received: by 2002:a50:d0d1:: with SMTP id g17mr15322686edf.96.1631563714491; Mon, 13 Sep 2021 13:08:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631563714; cv=none; d=google.com; s=arc-20160816; b=svudAAUuVj/+znymwowM4RQiShhiZ4vnwvqqmHUxTGphLlvsFK9/oigO4uF0zMW/1R xiqEN9WaRNVSGCtVFOZvnIW6mNnVGIacqoxNfJ6CG15jsC6tkVWqbSFTUniZO/Y0/FU7 rhFK7kBL5quBRRXV+RfKkc5HVKJu/GjNoSohcrzR7e/5yAZ7p5I1oc3OI0yQfjTP7gPS TnlfCdlvAafi4tvYsjQdwcYRaYy/MmoHlxqxw2+56eQNJwBS1cXfQTwPMKT7+yzN2eVw mP5AFNvLIwf2UraBcOKK0Nj9uNj2jzzBqqWpHbydYOrnAg8kap6mlA0Unq4vztRcw/1K hsoA== 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=IInXLALS/LdeoEbFpqfkTIVySRyPgPcGq3SXyrDiHHc=; b=0eVBqw8QecblisW9VAMMAe5UKur69QqRosD7MvyFlWKd3eaCtSy2NcoDdhcSU7sh5T GdYdHziZSI3b6gNeskgKou9vimYxOhOy7mCIHAi1UPYFFPJqE2iXXcvfXk+OOdNkkEZ8 JhhFFOkpal349YtmXF+aI6yqUW+Wbl51rGN3k9/wa9sMMHpiKD1OqviFRb9YPzVEthUw OibfvP3SZQOBKolPTGDbVb89lDsOJ4qm1encTMeQDNQeD1ACZm8XmxbTFoFqbrqJX8i3 P73zS7Jz6M5Uhk4PYQ82rR1cCx57rPNwchG+y6G8aJibw+4klP+crNknxFd5MLk2vVsN ViqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="F8E7sQM/"; 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 jx24si7125172ejc.460.2021.09.13.13.08.10; Mon, 13 Sep 2021 13:08:34 -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="F8E7sQM/"; 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 S243359AbhIMNrg (ORCPT + 99 others); Mon, 13 Sep 2021 09:47:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:46760 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240811AbhIMNmH (ORCPT ); Mon, 13 Sep 2021 09:42:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B81186128A; Mon, 13 Sep 2021 13:30:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539812; bh=OOscOqLtTwZQiu644CihXV17xrXGCW19bhSfM2xPhy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F8E7sQM/dIKXwS/If/RRYeONI9wfUm9/j3/54hgh6NlgPgk9F0jxqS1Ii5NIuIxxX mIiR2fcP24TjK15TxWTsSmWxmeF9NoLiEPsBdfwL43UF/jSWA+GulLAmUrxemYF7FU unxMElZf5jLqdQJyYsG4330yX+va5p5+5X7Y2050= 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.10 137/236] counter: 104-quad-8: Return error when invalid mode during ceiling_write Date: Mon, 13 Sep 2021 15:14:02 +0200 Message-Id: <20210913131105.019593985@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131100.316353015@linuxfoundation.org> References: <20210913131100.316353015@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 78766b6ec271..21bb2bb767a1 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -1224,12 +1224,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