Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933678AbcJLWvM (ORCPT ); Wed, 12 Oct 2016 18:51:12 -0400 Received: from mga07.intel.com ([134.134.136.100]:14117 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933296AbcJLWud (ORCPT ); Wed, 12 Oct 2016 18:50:33 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,485,1473145200"; d="scan'208";a="1064028051" From: Ross Zwisler To: linux-kernel@vger.kernel.org Cc: Ross Zwisler , "Theodore Ts'o" , Alexander Viro , Andreas Dilger , Andrew Morton , Christoph Hellwig , Dan Williams , Dave Chinner , Jan Kara , Matthew Wilcox , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-nvdimm@ml01.01.org, linux-xfs@vger.kernel.org Subject: [PATCH v6 06/17] dax: remove the last BUG_ON() from fs/dax.c Date: Wed, 12 Oct 2016 16:50:11 -0600 Message-Id: <20161012225022.15507-7-ross.zwisler@linux.intel.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20161012225022.15507-1-ross.zwisler@linux.intel.com> References: <20161012225022.15507-1-ross.zwisler@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 776 Lines: 26 Don't take down the kernel if we get an invalid 'from' and 'length' argument pair. Just warn once and return an error. Signed-off-by: Ross Zwisler Reviewed-by: Christoph Hellwig Reviewed-by: Jan Kara --- fs/dax.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/dax.c b/fs/dax.c index ac28cdf..98189ac 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1194,7 +1194,8 @@ int dax_zero_page_range(struct inode *inode, loff_t from, unsigned length, /* Block boundary? Nothing to do */ if (!length) return 0; - BUG_ON((offset + length) > PAGE_SIZE); + if (WARN_ON_ONCE((offset + length) > PAGE_SIZE)) + return -EINVAL; memset(&bh, 0, sizeof(bh)); bh.b_bdev = inode->i_sb->s_bdev; -- 2.9.0