From patchwork Tue Apr 10 09:49:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 896563 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 40L2T752Gxz9s3Z; Tue, 10 Apr 2018 19:49:47 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1f5puJ-0001Uq-RY; Tue, 10 Apr 2018 09:49:43 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1f5puI-0001UW-3X for kernel-team@lists.ubuntu.com; Tue, 10 Apr 2018 09:49:42 +0000 Received: from [175.41.48.77] (helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1f5puH-0001fW-CW for kernel-team@lists.ubuntu.com; Tue, 10 Apr 2018 09:49:41 +0000 From: Kai-Heng Feng To: kernel-team@lists.ubuntu.com Subject: [Bionic] [PATCH 2/3] usb: core: Copy parameter string correctly and remove superfluous null check Date: Tue, 10 Apr 2018 17:49:30 +0800 Message-Id: <20180410094931.22512-3-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180410094931.22512-1-kai.heng.feng@canonical.com> References: <20180410094931.22512-1-kai.heng.feng@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1762695 strsep() slices string, so the string gets copied by param_set_copystring() at the end of quirks_param_set() is not the original value. Fix that by calling param_set_copystring() earlier. The null check for val is unnecessary, the caller of quirks_param_set() does not pass null string. Remove the superfluous null check. This is found by Smatch. Fixes: 027bd6cafd9a ("usb: core: Add "quirks" parameter for usbcore") Cc: Dan Carpenter Signed-off-by: Kai-Heng Feng Signed-off-by: Greg Kroah-Hartman (cherry picked from commit a030501499b032bd218e1d01c07677bab6a0d53f) Signed-off-by: Kai-Heng Feng --- drivers/usb/core/quirks.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index 11d943a6b7cb..a4f53e1f1ce1 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c @@ -31,10 +31,15 @@ static int quirks_param_set(const char *val, const struct kernel_param *kp) u16 vid, pid; u32 flags; size_t i; + int err; + + err = param_set_copystring(val, kp); + if (err) + return err; mutex_lock(&quirk_mutex); - if (!val || !*val) { + if (!*val) { quirk_count = 0; kfree(quirk_list); quirk_list = NULL; @@ -133,7 +138,7 @@ static int quirks_param_set(const char *val, const struct kernel_param *kp) unlock: mutex_unlock(&quirk_mutex); - return param_set_copystring(val, kp); + return 0; } static const struct kernel_param_ops quirks_param_ops = {