From patchwork Mon Sep 11 09:00:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 112173 Delivered-To: patch@linaro.org Received: by 10.100.153.131 with SMTP id 3csp5468873pji; Mon, 11 Sep 2017 02:00:37 -0700 (PDT) X-Received: by 10.99.186.69 with SMTP id l5mr11013163pgu.160.1505120437569; Mon, 11 Sep 2017 02:00:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505120437; cv=none; d=google.com; s=arc-20160816; b=jDDW+y5rIsY7mv1+bmSdRUK+J9Dlkgs6hs/InojWjhKDr5cVtmnfK5pOHh7S1f337V sL9zugqSF68WPM62dUypmindeCZ83cBtYRcx+WzbIcTWPbowKeOnWNEBdZiC4t9hosIq 7/ShWhzfEqBNX7zjlNelpG7WEgQPH6fN1MKKcSy1jqu0j/PzoJXOnHrxW6iFA8l4Pr13 HvPXme78XmV2wdmqVBRlXFw7vUWNc6pfNAszMkYJvswFpALPu8n3zX5fFVM5SzICJS2W mC+9wOWoDnY5ab8Ij5zqlwMiM7yoCVtadbReCFtLsVJO6rG5KSHse+ZrY2TEsKheXyOl psNA== 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=Fl+JdvX0/Kiplt78R/cZRIKfpI5lQd8kRL4PAfOWyY8=; b=STODooQErGsJ2nayG9fqgXyoz5DqEV808tD8jd3zTIq7bCrMI5YuXh/ZomkKfuKBmm aQw7Oxqvmddk1xuSosWL7oZbiGbD76gWhIiiwl+dwOrlTYFPSK9Sw001E+KqRjYOgqS4 b+3i1uKGorm1n8FmcPzllJIzXNZKDgj3sUgPUvBFRZk7VXyEC1+mX7XnMotr002HswdN X4g680FbXDJUhX4QjmNidwdv5VBY5nVx9o0pZVQoxqZEIBpgWhV+jv8Z2EqAw5IIl+eB 2fqLMUy5iD7wQiIQbEAN4xdHC/LA88IDQfZwrKj8/my+rlZXIgAFMN7cu1B9xHKB2caO 52oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WwhbQtXk; 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 h185si5832268pfb.398.2017.09.11.02.00.37; Mon, 11 Sep 2017 02:00:37 -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=WwhbQtXk; 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 S1751357AbdIKJAd (ORCPT + 26 others); Mon, 11 Sep 2017 05:00:33 -0400 Received: from mail-it0-f43.google.com ([209.85.214.43]:43705 "EHLO mail-it0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751292AbdIKJA3 (ORCPT ); Mon, 11 Sep 2017 05:00:29 -0400 Received: by mail-it0-f43.google.com with SMTP id g142so10795647ita.0 for ; Mon, 11 Sep 2017 02:00:28 -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=Fl+JdvX0/Kiplt78R/cZRIKfpI5lQd8kRL4PAfOWyY8=; b=WwhbQtXk1bZEvl5xccxK3ealFMnZhBklx3Tk7S0UFkDXUwMqrjAqEFHLLI8YGf5cU6 Fn1olxTs0XO4AO3swsbdIgtTb4oe2Xl+oJ/XXYpbHaLr/lqS2rVt+uFCHmw3pyGeuA5M GfG/qsH+Wt/JcjQVLrnxlqNpQolrX9hJXlv6I= 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=Fl+JdvX0/Kiplt78R/cZRIKfpI5lQd8kRL4PAfOWyY8=; b=pwF5DNZ0lvP4llk/neSikA1W/ZF38d402Jh4o7vzxa+ggz4koYpyVUSv95Fn7m+cJb RQPxe+u9t4ng0HEsAUVXLhv2xZTsGCdsI/fGOuXQbEUULK+Dur28vHNau4iVHY9UtOuv EYQdCiR4ykCcU1gSjUsgGck3r7rv2HohPZkyAso2AKfzmLYZVI/nzz73LVKIawyxr/JX AK6LeYMnDm3ELUjjWkzTMiXdIn61Qhe6NKKGQ/u9Pxv2Qxn0fQT/MZfA+hlF2/eAkwvy 0Lj08kriXpsKZfuom4B4qh6z4XGhe1USxJRun/2UFpvNgEKZ3tejQs9NSPpAPPE7IVq3 MDDw== X-Gm-Message-State: AHPjjUjW0kBXE6OzCr39lIV0NcH0uG8g/YXXLYUKW6/9cshYQ8jPX3Dn ZI3xMJmSpQHOsRZe X-Google-Smtp-Source: AOwi7QCpd8Z1S7Ntr9ERLLPVKmMTm9yyE7dI2bkoQ8vHneo7/zctH3uPJLNzFGslh0dy6cxd9ynC6A== X-Received: by 10.36.61.15 with SMTP id n15mr11251054itn.117.1505120428324; Mon, 11 Sep 2017 02:00:28 -0700 (PDT) Received: from localhost.localdomain (static.8.26.4.46.clients.your-server.de. [46.4.26.8]) by smtp.gmail.com with ESMTPSA id a189sm4344146itd.21.2017.09.11.02.00.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Sep 2017 02:00:27 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Guy Shapiro , linux-api@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 1/4] nvmem: core: return EFBIG on out-of-range write Date: Mon, 11 Sep 2017 11:00:11 +0200 Message-Id: <20170911090014.16806-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170911090014.16806-1-srinivas.kandagatla@linaro.org> References: <20170911090014.16806-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: Guy Shapiro When writing data that exceeds the nvmem size to a nvmem sysfs file using the sh redirection operator >, the shell hangs, trying to write the out-of-range bytes endlessly. Fix the problem by returning EFBIG described in man 2 write. Similar change was done for binary sysfs files on commit 0936896056365349afa867c16e9f9100a6707cbf Signed-off-by: Guy Shapiro Cc: linux-api@vger.kernel.org Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.3 diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index de54c7f..3866117 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -135,7 +135,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj, /* Stop the user from writing */ if (pos >= nvmem->size) - return 0; + return -EFBIG; if (count < nvmem->word_size) return -EINVAL;