Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1111720imm; Wed, 1 Aug 2018 10:22:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeCIvaQg6q+OY0fjERaz7ggWWUJMdM+Vvh6XlA666ovCUjEo0v7BmkymQA+TANdTzu/IRFn X-Received: by 2002:a62:864a:: with SMTP id x71-v6mr28060179pfd.252.1533144129670; Wed, 01 Aug 2018 10:22:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533144129; cv=none; d=google.com; s=arc-20160816; b=SAx4yzRulAIx7RrcliWODQ269MVw/K59VQ4VhjEFbZY5gwO4F3D9nWStfN33H/vXp7 r5atUaVVpUFtUqMuimO4KQPBAP9EBTA4RjwTi0yFavsi/SDyLgEvO9fO5BOz+DyLtE0n 8vPJYgnAsK1yeUZ5Twf3yoVVRuUb+f9HQO913mhKuIcz2g61eQV/Mh7YM1aIpSSynga2 op4Rw6sByn2PQ7nGmV7yc2cVaBQUq83TQvm5lfh+5jdUKJyZ0d9iBtSZh6jshQd1SZ53 s2ytTtUYvD+1MuOWQo4fEsCBV9irry5p99El1JiL4nGzZ+gthyWFUnUQTbaq8YgZMitg jfSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=8K5moNjN9/VLFZjkz2DRtTcztuyP0r3KT9VnJZjPRqA=; b=H5aEkyRTpdYKyvKMhdY4KgomeTJRhOCnBXR7gBp2zSh7lV0ssuXh4n3t7rjJXHbusC DZUirmgSl2BtGT4zSwSeYJZpq4ZEy3Jve1CP/kzu669UyIAzr+2E6QL/J3sZJeHu+i4Z BMgsxddge+R1ZnBnftkdoHkQ2lEvAUmRzwyzuUWvq0FD+sFxjH4SReoSNPr2LxWxl9Wp GPdvVPQCGhvar5lz9jQCgfjo/SSqtJJBnB4C2jK/DEiYLmSsAe1016nkFLX3FAXfhVW0 CkJAyeyxn8I5xfOwkXJs8r2UPNPVexip8qQ9x27tN5NBSpUdtDlHXSh9clZNscdbjTWV ovoA== ARC-Authentication-Results: i=1; mx.google.com; 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 e1-v6si17672414pfa.274.2018.08.01.10.21.54; Wed, 01 Aug 2018 10:22:09 -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; 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 S2405130AbeHATFt (ORCPT + 99 others); Wed, 1 Aug 2018 15:05:49 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48064 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403884AbeHATFs (ORCPT ); Wed, 1 Aug 2018 15:05:48 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E9026D15; Wed, 1 Aug 2018 17:19:07 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathieu Malaterre , Srinivas Kandagatla , Sasha Levin Subject: [PATCH 4.14 145/246] nvmem: properly handle returned value nvmem_reg_read Date: Wed, 1 Aug 2018 18:50:55 +0200 Message-Id: <20180801165018.667265583@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mathieu Malaterre [ Upstream commit 50808bfcc14b854775a9f1d0abe3dac2babcf5c3 ] 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 Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/nvmem/core.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -1049,6 +1049,8 @@ static inline void *nvmem_cell_prepare_w /* 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 */ @@ -1067,11 +1069,16 @@ static inline void *nvmem_cell_prepare_w /* 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); } /**