Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp684643ybv; Thu, 13 Feb 2020 07:44:08 -0800 (PST) X-Google-Smtp-Source: APXvYqx4Y+6SLwRn4JmpYwQc6l2KK+Lve0guniqYZmgRvz1VsULjYAe5jjonx0qMJJS87shN/JqL X-Received: by 2002:a05:6830:154a:: with SMTP id l10mr13975070otp.44.1581608648383; Thu, 13 Feb 2020 07:44:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581608648; cv=none; d=google.com; s=arc-20160816; b=bMiNiPQ8G0B3PeTtnR0L8zkwIOXKwCKVxeG0y0pYfqxQZzBfLW2gcMBLdo90SATuSb YlJSQ0BJM9oxIGT5eOEom4boO5Lqno5IEQxLi6IsRNRz7CmXPrFI3jXvegmyDqhCIRI+ mWjTFF9bk5tjMV1c1nlXjkh5ICu8A/7GJMexE0vNO2lZVCMK18/y+a6Jnxw3Zm/ghj3I ugEkY2uF7DXDGaKJ1noKhp+N0WGLVTxc9cWD+lIAmjE+wsgSew4LmUl0QmcyLTF939xe EkG38iIVCRXeE4BxgDoFJGTFqt/EaVye+C6n1iL3xNRd0lqSTI/2cOvDxAG92KOM0zOz wOCg== 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:dkim-signature; bh=qKUiGcspYepWQHQZRTKeuSCnhthPMdrMbO9OsW5UIaA=; b=CMmRm7FppUdMFhbGI/00E/LG87mPAUknLOjbpEl0QXXEI9pPKMjlaDJ0LZggIEFcv4 VGZN4xdiwE9bD3WRrRjWv0a6LqN2sv4RNmL1PqrULanQfLMYowZ82URlAVB8UMVt3oPF PPkJvC8pPU82fr9Tzx9N1PUqPYU2x3RwmCXhvNxfFxaUWJYGgnyokNdg2nxNmh4SqFv7 kp+zVYO2Iqg2YIM/mIxqSzAg39guZgAqLxtB0mBfYy4Mbgcv2nKFy0Uq3e277bddiLTZ NjiZ4CgtCC/ifpO+XU/Qb8oFQtcquUG2Vp49ydxgfGFIHsGQXxxMBVwaXAYs07HSqb1e likQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fQQ0LdSP; 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 y71si1379308oia.82.2020.02.13.07.43.55; Thu, 13 Feb 2020 07:44:08 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=fQQ0LdSP; 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 S2387410AbgBMPnw (ORCPT + 99 others); Thu, 13 Feb 2020 10:43:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:52406 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387706AbgBMP1s (ORCPT ); Thu, 13 Feb 2020 10:27:48 -0500 Received: from localhost (unknown [104.132.1.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 65A2A20661; Thu, 13 Feb 2020 15:27:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607667; bh=MRdGMjutinYGYiS4uueb/cSnR9n8EX3kqsC1u8p/7kI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fQQ0LdSPn+6DjfaKxEHplbBccfLzGFSvFuQi/+Wqmq1k+6khh2slPO3NiY0al2VsW b+czQSkOidNq10P3TiEiwVeZkO3YqRDCHxuZSZyuqFeTuSDm8ssOiS9gzfTAkcVdN1 WqmijvOfGcfvtoCgp0l1OwOSx0r3j+r0YhqQsUX8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ben Whitten , Mark Brown Subject: [PATCH 5.4 89/96] regmap: fix writes to non incrementing registers Date: Thu, 13 Feb 2020 07:21:36 -0800 Message-Id: <20200213151912.406961661@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151839.156309910@linuxfoundation.org> References: <20200213151839.156309910@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Ben Whitten commit 2e31aab08bad0d4ee3d3d890a7b74cb6293e0a41 upstream. When checking if a register block is writable we must ensure that the block does not start with or contain a non incrementing register. Fixes: 8b9f9d4dc511 ("regmap: verify if register is writeable before writing operations") Signed-off-by: Ben Whitten Link: https://lore.kernel.org/r/20200118205625.14532-1-ben.whitten@gmail.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/base/regmap/regmap.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1488,11 +1488,18 @@ static int _regmap_raw_write_impl(struct WARN_ON(!map->bus); - /* Check for unwritable registers before we start */ - for (i = 0; i < val_len / map->format.val_bytes; i++) - if (!regmap_writeable(map, - reg + regmap_get_offset(map, i))) - return -EINVAL; + /* Check for unwritable or noinc registers in range + * before we start + */ + if (!regmap_writeable_noinc(map, reg)) { + for (i = 0; i < val_len / map->format.val_bytes; i++) { + unsigned int element = + reg + regmap_get_offset(map, i); + if (!regmap_writeable(map, element) || + regmap_writeable_noinc(map, element)) + return -EINVAL; + } + } if (!map->cache_bypass && map->format.parse_val) { unsigned int ival;