Received: by 10.192.165.148 with SMTP id m20csp4084741imm; Tue, 8 May 2018 02:39:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp50lzSwA41a+NN6aE+QW/l8PiL81ZAI1N17MmNJmcpxMg3GrpNUfQ/dJ9gpMuuzXOD3fva X-Received: by 10.98.68.156 with SMTP id m28mr33655699pfi.145.1525772362398; Tue, 08 May 2018 02:39:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525772362; cv=none; d=google.com; s=arc-20160816; b=F97I2gwO8yCcObabohOHAGeln40LskiCIBF8NQknXN8+0gpn3x7iqHg7JLO5PkJUV5 GQeJiF7Kaa+WTfUpKGu9xCKw/fLDSKlJ1mkqrL2VcAgV1PpVH+qiZxcq1R/KAxa4Xwv2 q8y0F6pbnr4JWgqLGmQpuWo8cDRyJLnc0VmnLpoLj0IJWXm4bPQjmnx4KHHBlRMTy/eb OapCHyXCibt+EqQDmTikiRkVCBL5YtzYcKuwWjchYVCmV+AnTd451EJM+oOTdzqVpNnt HqJsa/S0APJFaMJjiNL6Qvih9Z8Ps+hMWgoLdTumxWEFDPMu+OzSm+H4/tV+bEORHQt5 74NQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=ICa7P/zRY5beER1T0TKjf3U4XoClRnz/urQknG7sEaQ=; b=zIVeNfY7eEyM4mnrTj5XVSy1USRsWUqJ5qJAwGFaMBmwnKoeP0nbZuyIdqjAJ67VhF 5BN6LXXfeJH7xVyjn87wJjxVXbRBOO7WoOMLo0VI39g+98iO5mqRTSHzMMYdfMGbM4wB puEXu2qcrMepxewKpZ5ZKmWbv61hk7gUO7rAD69D1v1av3vvevCYkXUgwMeIp+eDd1J6 WBLdLNjBaximHIBakQHqzITTRBklsI9XDRJZcHDG15AYIOkspdlYHGoT9vYUy+TiyoVj AhM8UrkeoRGtJ1PC03QgjlIc223ELgTzKxtvAtrt9sD5+7jBQ28gLNzuiCfV7eDIybVf yknw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kD5N2qgV; 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 g2-v6si23043141plt.421.2018.05.08.02.39.07; Tue, 08 May 2018 02:39:21 -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=kD5N2qgV; 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 S1754786AbeEHJaW (ORCPT + 99 others); Tue, 8 May 2018 05:30:22 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:53637 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754457AbeEHJaU (ORCPT ); Tue, 8 May 2018 05:30:20 -0400 Received: by mail-wm0-f68.google.com with SMTP id a67so17576652wmf.3 for ; Tue, 08 May 2018 02:30:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=ICa7P/zRY5beER1T0TKjf3U4XoClRnz/urQknG7sEaQ=; b=kD5N2qgVmWnB0wDc3F9ltvn1PJXjaMMfPTTBRR3m89GaMwPogQYw6sVlyV7MrkeiDN zxbSUaY4padBb+P/y/KP+QuqMINtILnEPaeITDiRsYzmDW+nRgrb5NQNRbppxrWTKPKg mvAcb9PYnwWWymTsobsFOgMO6QYwH/sNbN7Uw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ICa7P/zRY5beER1T0TKjf3U4XoClRnz/urQknG7sEaQ=; b=mYn4+4V4Fu83wWiOqt18NYYVF1IaZHsxhqxpORMY9uqjy1b0sPeB0jtLQVe91KLfgR sHA0utIRgm1QyiqiiAyXg+15WuCA7fqJ54AKESXh8RiXIZ6PZ4oiDzYdJhkLhXDrqjyD KVjBVTXWT7mVhnxbB0bZ4akNFhTNV2GsjWYGg307cQEyw6nCPqTJQbD/fMuyaIf3l/ab lkA/vnONdIHo3Me57oK+ZpvY4vwGuGymEhOw08WL612FIMPsK6Sn90C7kccZIWz+HjQv S8sixopYZQm9el8HrJieINgNWOasz6ryjcSt/oTq196ay1Ic3ARnOQaYLKumd0KK0Sll EyjA== X-Gm-Message-State: ALKqPwfBqEneAB9hs6AMrTNlbU1jbvr+vNIVs/fZqShOlXLHA95WvBnb MonUqZQEHlKmdOegBEjKxiED84/LUZw= X-Received: by 10.28.35.72 with SMTP id j69mr2766701wmj.45.1525771819462; Tue, 08 May 2018 02:30:19 -0700 (PDT) Received: from [192.168.0.18] (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.googlemail.com with ESMTPSA id x7-v6sm17109370wrm.35.2018.05.08.02.30.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 02:30:18 -0700 (PDT) Subject: Re: [PATCH] nvmem: properly handle returned value nvmem_reg_read To: Mathieu Malaterre Cc: linux-kernel@vger.kernel.org References: <20180505202450.26630-1-malat@debian.org> From: Srinivas Kandagatla Message-ID: <86ae1cf5-8145-63f1-1464-973aeb056103@linaro.org> Date: Tue, 8 May 2018 10:30:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20180505202450.26630-1-malat@debian.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for the patch, On 05/05/18 21:24, Mathieu Malaterre wrote: > 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; You should return an error pointer here, not NULL. thanks, srini > } > > /** >