From patchwork Fri Dec 15 13:42:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 122097 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp489667qgn; Fri, 15 Dec 2017 05:44:39 -0800 (PST) X-Google-Smtp-Source: ACJfBovewj5Wsw9xJtZbatMKpMVekJh/w0bJbJWKAAA/Q8IwlDxmIFQiwgW4rgLPmZSnLwWIQ1wx X-Received: by 10.99.66.68 with SMTP id p65mr12170487pga.339.1513345479553; Fri, 15 Dec 2017 05:44:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513345479; cv=none; d=google.com; s=arc-20160816; b=djePhU194R3Ofu0Dk10Bs79kXMcTKIQC8peXS7DmVvpgnVRkEQWAZkuK5pzH1m67B6 GexIwGNXrGSv3wUmlej38LFhnixpgAyoUC0r5PsFox3bfE9QILJR2gGHHUxAcrQtnOU+ tMCINole8SaZdG+hJ4XeiyozIiuMy+PIrsdv1kUtP3BpSlAJOQCS+DoHh5LKRFNvv+lU dEiakmHPj+NFQAf6mAHFIC3Bm6m3HMEOGqtJv1uNNepabckg5b+mleLdqlpJoHQDvuth hz4l9OBLszaZA079uVZpv6FbsD/CpIDbKKWoFQqtMUjV+CaU2FX+Ah3f7FP+uuOGSpGq hc7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=UA8p3VG8DEuksGvfRD/8/+QBFl0YZYGLlVhzziw8fAg=; b=R02ViaCCjLFCK+7YVcr7ZczPSmz4mCq3/I0eanv5nwfIpSyJskw6NDHLlgOKiz7jRt MPk7LOI77AmiNu0RQdPIBvS6nYRM85h90PFu6b3lUxCzus6xK446sNyFVj3AVVNOgTo2 kXvv1R1ILYcbeBOr/7oAA9h2s1Jc2jZrhbvza3dTBx/fOBsiOAQeLBzp++1lLQMHMEMY Xy/Y1ESUxRH9p368qkjmj+DR+MMyq9AiePBHE8eiEou3osMqI/Lc2xRFid9oVgJDAjUq DgRrlR+yO/rNVzrKhUfrciRzbNqZEMGX169ZRUake7QNBtBkI/AxJLBaY133c/cE+lDG 4fzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HlVGaACw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e39si5012752plg.100.2017.12.15.05.44.39; Fri, 15 Dec 2017 05:44:39 -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=@linaro.org header.s=google header.b=HlVGaACw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932070AbdLONof (ORCPT + 20 others); Fri, 15 Dec 2017 08:44:35 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:42325 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756221AbdLONoe (ORCPT ); Fri, 15 Dec 2017 08:44:34 -0500 Received: by mail-wr0-f195.google.com with SMTP id s66so8090837wrc.9 for ; Fri, 15 Dec 2017 05:44:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=UA8p3VG8DEuksGvfRD/8/+QBFl0YZYGLlVhzziw8fAg=; b=HlVGaACwS2+RQqfz3wwFkKaiinXYr8WLIl60r/+imqlSOJipakXn6cQF143G59ek7R aXi5z9hXRdCecqrMQ4r+TR9W26pYOnfByMWTI4+f+BnEedxMZIwmRhOyuYjkdPS+lTFF dydDRKIW0FwCY0Ry2kYN6/Q0rZ8TtzOxS49DI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=UA8p3VG8DEuksGvfRD/8/+QBFl0YZYGLlVhzziw8fAg=; b=I9+VVDhm2/hIZ7z9l0YfbrEZGa0vpqWRnUvdU22HiiRbKSrEDckc+6jErjYHNazIUv 6ggSMYepNj9zfTsZKpGhlK8MdlNG30DokDJ3Z2Q5gVP9/kTl+RlVw3x/SGfC32TnrGX/ Yry0NYbggf9bs4Kx6hb453CPcBSmarZFqJHoBgLwxko6QFtrfhgmbENq/Uxk2pCEJzgv /jRPVE2RgYXg257POHy/4vWWiJ1YdJlBmYgoC0V48B7y8zsmB7fWomj0Yf29PRCJ9pdN 3meRVM85fwr3szN7j59z4MSMFzakgGBn54jkq7PxJlgNJnV4NgKB7ZOemdWQnzFLNT5y GHjg== X-Gm-Message-State: AKGB3mJtFoOBbsPT3ZJGzapwvUbdE06QPuS6XRYr2LzbUdnMKgMEG0vj BecX6r2acJySoUzdshyPtCmgTQ== X-Received: by 10.223.191.13 with SMTP id p13mr10225851wrh.69.1513345473155; Fri, 15 Dec 2017 05:44:33 -0800 (PST) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id f90sm7884384wmh.12.2017.12.15.05.44.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Dec 2017 05:44:32 -0800 (PST) From: srinivas.kandagatla@linaro.org To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, srinivas.kandagatla@linaro.org, Martin Blumenstingl Subject: [PATCH] nvmem: meson-mx-efuse: fix reading from an offset other than 0 Date: Fri, 15 Dec 2017 13:42:04 +0000 Message-Id: <20171215134204.28139-1-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Martin Blumenstingl meson_mx_efuse_read calculates the address internal to the eFuse based on the offset and the word size. This works fine with any given offset. However, the offset is also included when writing to the output buffer. This means that reading 4 bytes at offset 500 tries to write beyond the array allocated by the nvmem core as it wants to write the 4 bytes to "buffer address + offset (500)". This issue did not show up in the previous tests since no driver uses any value from the eFuse yet and reading the eFuse via sysfs simply reads the whole eFuse, starting at offset 0. Fix this by only including the offset in the internal address calculation. Fixes: 8caef1fa9176 ("nvmem: add a driver for the Amlogic Meson6/Meson8/Meson8b SoCs") Signed-off-by: Martin Blumenstingl Signed-off-by: Srinivas Kandagatla --- Hi Greg, Can you pick this patch up for next possible RC cycle. Thanks, Srini drivers/nvmem/meson-mx-efuse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.15.0 diff --git a/drivers/nvmem/meson-mx-efuse.c b/drivers/nvmem/meson-mx-efuse.c index a346b4923550..41d3a3c1104e 100644 --- a/drivers/nvmem/meson-mx-efuse.c +++ b/drivers/nvmem/meson-mx-efuse.c @@ -156,8 +156,8 @@ static int meson_mx_efuse_read(void *context, unsigned int offset, MESON_MX_EFUSE_CNTL1_AUTO_RD_ENABLE, MESON_MX_EFUSE_CNTL1_AUTO_RD_ENABLE); - for (i = offset; i < offset + bytes; i += efuse->config.word_size) { - addr = i / efuse->config.word_size; + for (i = 0; i < bytes; i += efuse->config.word_size) { + addr = (offset + i) / efuse->config.word_size; err = meson_mx_efuse_read_addr(efuse, addr, &tmp); if (err)