From patchwork Fri May 11 11:07:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 135524 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp720567lji; Fri, 11 May 2018 04:10:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZobTw8EcoGEg07VwlnpWnfw8/cflaUSBqF8FN7lHfPuTme+tk0EzUXh/oLXO9fbi+lh1Sci X-Received: by 2002:a65:6085:: with SMTP id t5-v6mr1951646pgu.362.1526037049478; Fri, 11 May 2018 04:10:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526037049; cv=none; d=google.com; s=arc-20160816; b=RftRrNzrwRKhU17Xamfs7qEM6cgAKOY4d5z/4xZhMPrlM8zbIWRYlGVI6MdbIjDqrU pTpOeu1jnOqQbTZWvS7ZOWlYcaGAc3ink2BRnSJ/ba0pxpt4fDwR4jDOtv7xC6Uguupt OxdHzXQyf7ocwy6mfBygKB45iOngvMgSDUJWIjiFIl4x0VeXnA1AD0AjGPCOixVEXs+x 5hGAIcnjKPAiRSCFyTQVIxUDhnwGmaemPuIAEoNIju6gZNoLl7rNF5AavdIZRFqe77Y/ XnYiMCGPGIkwZMZE8kdDUepKUV9IJsyz8CnWLT5gokkXdnhe5wPyFUvpi4Upu/9S6h/n j5cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=w5TjQwKiVwpDnrp/KCzD6gMlzqCUY8K4AVpRvmhKkF0=; b=LCSEHJSV0tlGxOFWiiuGpcvG0eyJ+7b6oXuESSBNZ+ChzqVlPyAfK1irRg6XCRb2Ks YheAONeVMbIhO++jmvKDkUPN4zG7xIU+UCBYqPRSViopKRS6fiTf5dkq8cajoNAWg4dy r+hfggw174+Kstr79mcE2Lkuq0zfR4Bn+8VSVy6MBNPSaSUQ9f7sqmph7DUgvWnDaFo3 siW23hqpcfG5Tk7GwUswup6EIsnCE28pLAeJSvRvQV/2BWHh369M4+m045ymIXBiiZEU NOqz2qDXg8/baYaf4cIquUaezntU2epLrqk/wARJjs2W7+Df34Z6UiC6N7kaLrMDXmtn EgJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iYYkLbiT; 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 e11-v6si2256362pgs.476.2018.05.11.04.10.49; Fri, 11 May 2018 04:10:49 -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; dkim=pass header.i=@linaro.org header.s=google header.b=iYYkLbiT; 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 S1753563AbeEKLKq (ORCPT + 29 others); Fri, 11 May 2018 07:10:46 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:38869 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753451AbeEKLJi (ORCPT ); Fri, 11 May 2018 07:09:38 -0400 Received: by mail-wr0-f193.google.com with SMTP id 94-v6so4949961wrf.5 for ; Fri, 11 May 2018 04:09:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=w5TjQwKiVwpDnrp/KCzD6gMlzqCUY8K4AVpRvmhKkF0=; b=iYYkLbiTjpCBDnWUzymSo2hKmkC/6pI24txDlzP2rcTJYKSXSglGKJzL1DzcsQMKEl Lv1h4JhMzHV8SPUHzAf923ADk5MnimPxMAWbg1Am3f3P9kgxAW9fRJy10Bh+xesakBLE o3FmudmxB0SmjAwMHwpMiBygc48cxl0//tXuM= 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:in-reply-to :references; bh=w5TjQwKiVwpDnrp/KCzD6gMlzqCUY8K4AVpRvmhKkF0=; b=cf6aXLl6cGOY9mG9UI7hIVMoZtf9s9l3CSFkXXNM0NnXQ5e8K56ctd8dyesD+13Y3K icP1UowOC1MYZ72Ip1ANpTF8hJ06eENb6IrRF6b4HIFNqr6+kqC6BrVxr0BKjXw72c7y hogTdriK8r20szFvRbBEHCayuhZZR4mFc28WeySfWGTj20T77abRnhueq1j6Rq3ppG7m Mv6jd22ExScOovu847EveSf/vnIvcak/IeadmO1kN8opnUnRDP9qrvFmTDBmkG6lYTRn saIGSGKGhDZ7rEBzJtzSxnqpuXvNvULPQe1NORstmkwT9db9itBLI1zSqAjcV/+vZ/c+ 8C0Q== X-Gm-Message-State: ALKqPwfc4HEVizE4hoMCoCPCSz7vFaAep5GH+4e2hRSq8vBRdKRD6Bd5 cTjWugcIku8tuSC5OTKzGmOM7w== X-Received: by 2002:adf:a98f:: with SMTP id b15-v6mr4026533wrd.48.1526036976880; Fri, 11 May 2018 04:09:36 -0700 (PDT) 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 a129-v6sm714047wme.34.2018.05.11.04.09.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 May 2018 04:09:36 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, srinivas.kandagatla@linaro.org, Mathieu Malaterre Subject: [PATCH 8/8] nvmem: properly handle returned value nvmem_reg_read Date: Fri, 11 May 2018 12:07:03 +0100 Message-Id: <20180511110703.4924-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180511110703.4924-1-srinivas.kandagatla@linaro.org> References: <20180511110703.4924-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Malaterre Function nvmem_reg_read can return a non zero value indicating an error. This returned value must be read and error propagated to nvmem_cell_prepare_write_buffer. Silence the following gcc warning (W=1): drivers/nvmem/core.c:1093:9: warning: variable 'rc' set but not used [-Wunused-but-set-variable] Signed-off-by: Mathieu Malaterre Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/core.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.16.2 diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 36361044ddbe..b5b0cdc21d01 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -1119,6 +1119,8 @@ static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell, /* setup the first byte with lsb bits from nvmem */ rc = nvmem_reg_read(nvmem, cell->offset, &v, 1); + if (rc) + goto err; *b++ |= GENMASK(bit_offset - 1, 0) & v; /* setup rest of the byte if any */ @@ -1137,11 +1139,16 @@ static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell, /* setup the last byte with msb bits from nvmem */ rc = nvmem_reg_read(nvmem, cell->offset + cell->bytes - 1, &v, 1); + if (rc) + goto err; *p |= GENMASK(7, (nbits + bit_offset) % BITS_PER_BYTE) & v; } return buf; +err: + kfree(buf); + return ERR_PTR(rc); } /**