From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751865AbbKJJJv (ORCPT ); Tue, 10 Nov 2015 04:09:51 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:48428 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751750AbbKJJJr (ORCPT ); Tue, 10 Nov 2015 04:09:47 -0500 Date: Tue, 10 Nov 2015 12:09:24 +0300 From: Dan Carpenter To: Petr Vandrovec Cc: Jan Kara , David Howells , Andrew Morton , Al Viro , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] ncpfs: don't allow negative timeouts Message-ID: <20151110090924.GB2934@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This code causes a static checker warning because it's a user controlled variable where we cap the upper bound but not the lower bound. If someone passes us a negative timeout then I guess lets set it to the default. Signed-off-by: Dan Carpenter diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c index 79b1130..c07498a 100644 --- a/fs/ncpfs/ioctl.c +++ b/fs/ncpfs/ioctl.c @@ -525,7 +525,7 @@ static long __ncp_ioctl(struct inode *inode, unsigned int cmd, unsigned long arg switch (rqdata.cmd) { case NCP_LOCK_EX: case NCP_LOCK_SH: - if (rqdata.timeout == 0) + if (rqdata.timeout <= 0) rqdata.timeout = NCP_LOCK_DEFAULT_TIMEOUT; else if (rqdata.timeout > NCP_LOCK_MAX_TIMEOUT) rqdata.timeout = NCP_LOCK_MAX_TIMEOUT;