From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A44F7C433FF for ; Mon, 12 Aug 2019 13:50:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 757E4206C2 for ; Mon, 12 Aug 2019 13:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565617821; bh=+Ao2T+JW9I6b1V3DbH8L0V6nvIU+r21oCDVsEQiKJlM=; h=Subject:To:From:Date:List-ID:From; b=yc1KYdn3cx9FVGd2OekUlrMWddEiwr8ol6Io1rD8RbIBOeNubXOCiBccktP7ZRNsu S4PDOejBq4SWnBi6+9eEBW6Ec5Ik23idx7XReMQSmLErdOS/pb1UAoLcnADbolbW8l CfJgsS8NVAes3JSyotGUVxOIvKJ1Uk7AwO70zkNQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727066AbfHLNuV (ORCPT ); Mon, 12 Aug 2019 09:50:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:36088 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726703AbfHLNuU (ORCPT ); Mon, 12 Aug 2019 09:50:20 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5FE1B20665; Mon, 12 Aug 2019 13:50:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565617819; bh=+Ao2T+JW9I6b1V3DbH8L0V6nvIU+r21oCDVsEQiKJlM=; h=Subject:To:From:Date:From; b=Rrd3OFF7pmHWLHfpWVJVEZYeDtTnyW7556Kd48XuUUQsdpxNaAuPGkIWjXcol/adZ T+acpsIeSREmiiKaCUt9c9YFUUiyhoCYAgknTImR9ATlPtapcWShUrG5pSm2b8YGtT MuwUvQrH75gLDkr6BrwlwF9BmcQozDegiCgWrpoU= Subject: patch "usb: gadget: udc: renesas_usb3: Fix sysfs interface of "role"" added to usb-linus To: yoshihiro.shimoda.uh@renesas.com, felipe.balbi@linux.intel.com, geert+renesas@glider.be, stable@vger.kernel.org From: Date: Mon, 12 Aug 2019 15:50:17 +0200 Message-ID: <15656178172162@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org This is a note to let you know that I've just added the patch titled usb: gadget: udc: renesas_usb3: Fix sysfs interface of "role" to my usb git tree which can be found at git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git in the usb-linus branch. The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.) The patch will hopefully also be merged in Linus's tree for the next -rc kernel release. If you have any questions about this process, please let me know. >From 5dac665cf403967bb79a7aeb8c182a621fe617ff Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Wed, 31 Jul 2019 19:15:43 +0900 Subject: usb: gadget: udc: renesas_usb3: Fix sysfs interface of "role" Since the role_store() uses strncmp(), it's possible to refer out-of-memory if the sysfs data size is smaller than strlen("host"). This patch fixes it by using sysfs_streq() instead of strncmp(). Fixes: cc995c9ec118 ("usb: gadget: udc: renesas_usb3: add support for usb role swap") Cc: # v4.12+ Reviewed-by: Geert Uytterhoeven Signed-off-by: Yoshihiro Shimoda Signed-off-by: Felipe Balbi --- drivers/usb/gadget/udc/renesas_usb3.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c index 87062d22134d..1f4c3fbd1df8 100644 --- a/drivers/usb/gadget/udc/renesas_usb3.c +++ b/drivers/usb/gadget/udc/renesas_usb3.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -2450,9 +2451,9 @@ static ssize_t role_store(struct device *dev, struct device_attribute *attr, if (usb3->forced_b_device) return -EBUSY; - if (!strncmp(buf, "host", strlen("host"))) + if (sysfs_streq(buf, "host")) new_mode_is_host = true; - else if (!strncmp(buf, "peripheral", strlen("peripheral"))) + else if (sysfs_streq(buf, "peripheral")) new_mode_is_host = false; else return -EINVAL; -- 2.22.0