Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1953237ima; Thu, 25 Oct 2018 07:30:28 -0700 (PDT) X-Google-Smtp-Source: AJdET5eJhK3ZBQA6J8FUBGxVv7kc1x3v1eiFTEbDkYpBdFOzc2IOtDxmV4oyxwEF48T+N8rwg8lF X-Received: by 2002:a62:5ac3:: with SMTP id o186-v6mr1856975pfb.40.1540477828568; Thu, 25 Oct 2018 07:30:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540477828; cv=none; d=google.com; s=arc-20160816; b=vEaMHD5OVAwBZU8JbtnXQUc6+x7/JKS/uQbQ9jUiQ8OmPdchwQHSGdGe1ul0JTCfaB g+DNsWoGmYFp4ovd8mCl4/LlG/LkUSjshFnJ+E/PXU/xOJlVYJ85MVoj8d0vzEo0shHp /ruS9ffk1Syx2VIUNUMHqeB2ddHBTEYtBCLR1UslGTvQsaXzqqfpFNG92lMGq6vrqwPk t/e+Q4CdW8WrDqSZvDC0tpwN7Xx/xCcoycQiY463Q+kA06ZGsWK5sNKowyveXkvR0gkU oflIfbN32cJWgkUAwAhNqnKsnExC4PaMwaPcRqcMBHE+Cn+ABLkzcF5TXjm6hjlRNrZ8 QO6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=PuhHD6zmTaDJKG2G5sf+eEXLx18TryNalu1/rijyv+Q=; b=ULcZ8HXYe62pRTIMGCE0wfFjDQw9elHv9PgMDm43IJK5mItZ+6TXbpVcxnj/8JWMTN zqLz7Dqdr3UDU12OkCoUipcBSWS4CEFTIaGOQtKyZxY0J2a8+N+NCZqQFYpkOdv6sm7a e/cdRqKmxqzUHiiHOl35kQC11LMdRgWQJp1SPgQ5VLx16tcnKztln5IqvDS7cXaxxEUI 5IgVqa/HpEyX2his0tku5IuA3DzWspuXQKq1vmTxnNFknqed84ayK1zY+kqoQYmFFZec Ehb7XuicbzgL7pArcXnuhHBoLXz+D2Fgr60bVWTxaCGkc4+RVKlMWiQlZ4NWUkINMCe/ uBwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K9wL3Jau; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f35-v6si7995202plh.357.2018.10.25.07.29.52; Thu, 25 Oct 2018 07:30:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K9wL3Jau; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730475AbeJYWwU (ORCPT + 99 others); Thu, 25 Oct 2018 18:52:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:34236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730432AbeJYWwR (ORCPT ); Thu, 25 Oct 2018 18:52:17 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2773C2085B; Thu, 25 Oct 2018 14:19:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540477160; bh=pZ0LopufCPj98I+pErMges8QBFY34MAjoIVHUQJw/kA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K9wL3JauaLQC3do4rNUnhd2JDd0ZYm+rZVcXLn5PKRvlhT6TIT+w+cM5M+rQYzR1/ aGreJnqkRMYCR0VYvCeogHbwjUusNnmMmSX0HSYNZHo9LZFFoM4ppzw6R9IcKZUdSR gN9646Y4YHeIs7ZIM/+eclNP9gNAQTjtO3B8ZqOc= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Rasmus Villemoes , Felipe Balbi , Sasha Levin Subject: [PATCH AUTOSEL 3.18 15/98] usb: musb: Fix a few off-by-one lengths Date: Thu, 25 Oct 2018 10:17:30 -0400 Message-Id: <20181025141853.214051-15-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141853.214051-1-sashal@kernel.org> References: <20181025141853.214051-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rasmus Villemoes [ Upstream commit e87c3f80ad0490d26ffe04754b7d094463b40f30 ] !strncmp(buf, "force host", 9) is true if and only if buf starts with "force hos". This was obviously not what was intended. The same error exists for "force full-speed", "force high-speed" and "test packet". Using strstarts avoids the error-prone hardcoding of the prefix length. For consistency, also change the other occurences of the !strncmp idiom. Signed-off-by: Rasmus Villemoes Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/musb/musb_cppi41.c | 4 ++-- drivers/usb/musb/musb_debugfs.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index 2a535b70af21..3d69971156ea 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c @@ -629,9 +629,9 @@ static int cppi41_dma_controller_start(struct cppi41_dma_controller *controller) ret = of_property_read_string_index(np, "dma-names", i, &str); if (ret) goto err; - if (!strncmp(str, "tx", 2)) + if (strstarts(str, "tx")) is_tx = 1; - else if (!strncmp(str, "rx", 2)) + else if (strstarts(str, "rx")) is_tx = 0; else { dev_err(dev, "Wrong dmatype %s\n", str); diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c index 4c216790e86b..05d1b203f0d0 100644 --- a/drivers/usb/musb/musb_debugfs.c +++ b/drivers/usb/musb/musb_debugfs.c @@ -194,30 +194,30 @@ static ssize_t musb_test_mode_write(struct file *file, if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) return -EFAULT; - if (!strncmp(buf, "force host", 9)) + if (strstarts(buf, "force host")) test = MUSB_TEST_FORCE_HOST; - if (!strncmp(buf, "fifo access", 11)) + if (strstarts(buf, "fifo access")) test = MUSB_TEST_FIFO_ACCESS; - if (!strncmp(buf, "force full-speed", 15)) + if (strstarts(buf, "force full-speed")) test = MUSB_TEST_FORCE_FS; - if (!strncmp(buf, "force high-speed", 15)) + if (strstarts(buf, "force high-speed")) test = MUSB_TEST_FORCE_HS; - if (!strncmp(buf, "test packet", 10)) { + if (strstarts(buf, "test packet")) { test = MUSB_TEST_PACKET; musb_load_testpacket(musb); } - if (!strncmp(buf, "test K", 6)) + if (strstarts(buf, "test K")) test = MUSB_TEST_K; - if (!strncmp(buf, "test J", 6)) + if (strstarts(buf, "test J")) test = MUSB_TEST_J; - if (!strncmp(buf, "test SE0 NAK", 12)) + if (strstarts(buf, "test SE0 NAK")) test = MUSB_TEST_SE0_NAK; musb_writeb(musb->mregs, MUSB_TESTMODE, test); -- 2.17.1