Received: by 10.192.165.148 with SMTP id m20csp1488814imm; Sat, 5 May 2018 13:26:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpVAMejOwNXYSogmckfaf+AFdz3fjbQ6nO4uzvJS38GOSx5opCyWoBkRzY61OlmIIBejpCL X-Received: by 2002:a17:902:a5c7:: with SMTP id t7-v6mr24527149plq.360.1525551994051; Sat, 05 May 2018 13:26:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525551994; cv=none; d=google.com; s=arc-20160816; b=jvrg1gwOr3Nwx4S8Yt9Do3qY1XWrXgO8kHqd149ZUMN8/K/iezpi2OftiDAPYqOghs IOwWZQLVAZkcPL2rDyTwyQ0ktGHdoOl2y58FAFNrGgvuiHwUYsaesKf0IomIeIOdCk2K txdummQLoc9uKy7JnJqqS4rFZD53U09nU/4o3Nks/xjjUdq7nXESdn/VGUXDmReuOkrc ITSuTk0BYvWTLTUK9WXH1sGc2Ee6cruOUinUvT3TpQfRwtSIUcvk+5/s4q3YqEfuQrPs 567apuLn18x3k+Ob0Uc0dyZjotehnqyFiVNZHYoYV8Npa9D9zB5AAKLBWqyrcNnqyreN BelQ== 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 :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=2ywYCnZkBsOkFfs3V5rlSWeW0wZ5Gxs5rZkpzscgDgs=; b=JDa5JKzHOWzqSzsZgi3LtBsfvI9+rjMSvPjsf8FyJCeIXiUs+jCd+9aH7aDv8rhKhl eUN13PzMGTrDHnPVCUsgFJfR2ed9oLFSCBvlKuj/dOMRn01WNe8g0nusOJephe2Qu3TQ sJ19r2VyslVb5sE3JNhPkF0psiJxlG6uqHhaL/T7vBZn2IfT5vmtKB6VoVA/r66GbBFl MUgvMxFhVxhvoxK7kCZoJGUlidxQg9A+4yT8GYnQFNx3Sg7FzUuxOlECnp7Tdvwt8Gwz p+Na1ZYL3t82oYNFdofihsPPriZNSnAuV2rVqn+FMlUKaOiTXT3VaWA2AbaNYaDztCoj Z5dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ieLAvwPW; 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 j18-v6si15183430pgn.78.2018.05.05.13.26.06; Sat, 05 May 2018 13:26:34 -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=fail header.i=@gmail.com header.s=20161025 header.b=ieLAvwPW; 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 S1751845AbeEEUY6 (ORCPT + 99 others); Sat, 5 May 2018 16:24:58 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:41837 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751785AbeEEUY4 (ORCPT ); Sat, 5 May 2018 16:24:56 -0400 Received: by mail-wr0-f193.google.com with SMTP id g21-v6so24199035wrb.8 for ; Sat, 05 May 2018 13:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2ywYCnZkBsOkFfs3V5rlSWeW0wZ5Gxs5rZkpzscgDgs=; b=ieLAvwPWAQesYh2z+y+8i5arpR3s+K6Fa9c8/QxkFXJKhSWwayGWjKbFtuFNFnQWad RDh/t5wDi/JnFgSbV3Efswb+tv3tK+YDVjS2K06Bx7eCTSPpo/t4/0ffwQQU+s88EDDy VwSoRM1edylUvHZu1iw63Rs12mIgrJmwnnyP4niNE0j9VLn87mTdnSjfBuEXqHGJJ+zP 2dmYDcD6DX+YgKZtOKa/S11pf3gU2zGK9BOTqhLpGMczKvL1V02TMd9V1eD13z8qMLTd /BLCZd+pYSNMHHf2tIPRf+jixUYK8fUGBJPQtlPuYppZ5UAZVerh6qL+/TvxW59HCjXx xb5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=2ywYCnZkBsOkFfs3V5rlSWeW0wZ5Gxs5rZkpzscgDgs=; b=BhAsFUU6sWo6Nxb7+eOokwyW2N/HeYAWkhFVuZHLY5DJeLPRPp007WljpNZgSvcvAG yDqIaggJ63O2lCW2qM4FftxEu2anu5WFqBzFANRD0ftkIG44WXq9tfmhd3rGe/x90HIN G9Nteo4Ghc07uhZu9VeR5a8ZMu+eWtQjtfacUA0BScwDPxFXUOyWi7eWbtcjCpwMpvMh W3CZbNg8HrHw8zmG9XgQ/zx3hyAjURWkenqlrtmDknr/3609Ad3tArfU/2THPoB9bjpu qztkmeJ8UOxgKaOMPF23OW1wU36mk7/AXOwzDwyIbPuFtTRURcvx98Yd2kNqt0QKQrRu 5w8A== X-Gm-Message-State: ALQs6tDRg+RZpZ+dj2SPgnSFodfgly7ypSwNunb7OCzdFq7+h0QhWS4x wU9wUG+KUHs1MbnYW39ERNy3qp8F X-Received: by 2002:adf:a673:: with SMTP id k106-v6mr26806258wrc.231.1525551895010; Sat, 05 May 2018 13:24:55 -0700 (PDT) Received: from macbookpro.malat.net (bru31-1-78-225-226-121.fbx.proxad.net. [78.225.226.121]) by smtp.gmail.com with ESMTPSA id k126sm6371280wmd.45.2018.05.05.13.24.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 May 2018 13:24:54 -0700 (PDT) Received: by macbookpro.malat.net (Postfix, from userid 1000) id 34F7810C0604; Sat, 5 May 2018 22:24:53 +0200 (CEST) From: Mathieu Malaterre To: Srinivas Kandagatla Cc: Mathieu Malaterre , linux-kernel@vger.kernel.org Subject: [PATCH] nvmem: properly handle returned value nvmem_reg_read Date: Sat, 5 May 2018 22:24:50 +0200 Message-Id: <20180505202450.26630-1-malat@debian.org> X-Mailer: git-send-email 2.11.0 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 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 --- drivers/nvmem/core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index b05aa8e81303..f34f2363925a 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -1107,6 +1107,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 */ @@ -1125,11 +1127,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 NULL; } /** -- 2.11.0