From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757506Ab3AIJR6 (ORCPT ); Wed, 9 Jan 2013 04:17:58 -0500 Received: from mail-bk0-f53.google.com ([209.85.214.53]:33404 "EHLO mail-bk0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757438Ab3AIJRz (ORCPT ); Wed, 9 Jan 2013 04:17:55 -0500 From: Michal Nazarewicz To: Felipe Balbi , linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , Benoit Goby , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] usb: gadget: FunctionFS: Use kstrtoul() Date: Wed, 9 Jan 2013 10:17:47 +0100 Message-Id: X-Mailer: git-send-email 1.7.7.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit References: <1357703829-26621-1-git-send-email-benoit@android.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michal Nazarewicz kstrtoul() checks for overflow which simple_strtoul() does not pluss it has “*end == 0” check in it as well. As a side effect, a new line character is now accepted, but this should not be an issue. Signed-off-by: Michal Nazarewicz --- Patch on top of v3.5 with Benoit Goby's “Fix missing braces in parse_opts” patch () applied. drivers/usb/gadget/f_fs.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index 8c2f251..38388d7 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c @@ -1103,8 +1103,8 @@ static int ffs_fs_parse_opts(struct ffs_sb_fill_data *data, char *opts) return 0; for (;;) { - char *end, *eq, *comma; unsigned long value; + char *eq, *comma; /* Option limit */ comma = strchr(opts, ','); @@ -1120,8 +1120,7 @@ static int ffs_fs_parse_opts(struct ffs_sb_fill_data *data, char *opts) *eq = 0; /* Parse value */ - value = simple_strtoul(eq + 1, &end, 0); - if (unlikely(*end != ',' && *end != 0)) { + if (kstrtoul(eq + 1, 0, &value)) { pr_err("%s: invalid value: %s\n", opts, eq + 1); return -EINVAL; } -- 1.7.7.3