Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758644AbbGHNoK (ORCPT ); Wed, 8 Jul 2015 09:44:10 -0400 Received: from linuxhacker.ru ([217.76.32.60]:54510 "EHLO fiona.linuxhacker.ru" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754103AbbGHNoG (ORCPT ); Wed, 8 Jul 2015 09:44:06 -0400 Subject: Re: [PATCH 15/20] staging/lustre/libcfs: get rid of debugfs/lnet/console_backoff Mime-Version: 1.0 (Apple Message framework v1283) Content-Type: text/plain; charset=us-ascii From: Oleg Drokin In-Reply-To: <20150708082837.GL4341@mwanda> Date: Wed, 8 Jul 2015 09:43:48 -0400 Cc: Greg Kroah-Hartman , devel@driverdev.osuosl.org, Andreas Dilger , Linux Kernel Mailing List Content-Transfer-Encoding: 7bit Message-Id: <5262A52D-D367-46E5-A50F-E97F0B000111@linuxhacker.ru> References: <1436201338-14263-1-git-send-email-green@linuxhacker.ru> <1436201338-14263-16-git-send-email-green@linuxhacker.ru> <20150708082837.GL4341@mwanda> To: Dan Carpenter X-Mailer: Apple Mail (2.1283) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1393 Lines: 45 On Jul 8, 2015, at 4:28 AM, Dan Carpenter wrote: > On Mon, Jul 06, 2015 at 12:48:53PM -0400, green@linuxhacker.ru wrote: >> +static int param_set_uint_minmax(const char *val, >> + const struct kernel_param *kp, >> + unsigned int min, unsigned int max) >> +{ >> + unsigned int num; >> + int ret; >> + >> + if (!val) >> + return -EINVAL; >> + ret = kstrtouint(val, 0, &num); >> + if (ret == -EINVAL || num < min || num > max) > ^^^ > Smatch is smart enough to know that "num" can be uninitialized here on > some paths. It doesn't generate a warning yet because a lot of the > kernel has error paths where we mostly assume things won't fail. > > It should probably be: > > ret = kstrtouint(val, 0, &num); > if (ret) > return ret; > if (num < min || num > max) > return -EINVAL; Hm, indeed kstrtouint can return errors other than -EINVAL. In reality this code comes from net/sunrpc/xprtsock.c and I failed to see the problem there while copying. This also suggests that the type is might be enough in demand to make it generic so that people don't reimplement it themselves? Thanks! Bye, Oleg -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/