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 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 C7FEAFA372C for ; Fri, 8 Nov 2019 07:19:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 992BC2178F for ; Fri, 8 Nov 2019 07:19:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573197564; bh=T/WLXFZwFHW1jqB3cosDbY/Xg53P2HiB6HnniPKJUfI=; h=Subject:To:From:Date:List-ID:From; b=0Da48lXKyF0NR9PfHdbnBmEUIfDrOANJrLEsDkUrkvmSiwK7MzPCtSskHihoawDJd 4oB88CRZjqXOEEx7qEijpTJKSwJuzHAY+dCRpgCaZdE5yLoyERffEgJarG1ZuRALU7 rxEf5kuUJpSmb2hHZI2s/BpARtu0FX0LwDiyE77s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726672AbfKHHTY (ORCPT ); Fri, 8 Nov 2019 02:19:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:42186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725886AbfKHHTY (ORCPT ); Fri, 8 Nov 2019 02:19:24 -0500 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 D43EF2085B; Fri, 8 Nov 2019 07:19:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573197563; bh=T/WLXFZwFHW1jqB3cosDbY/Xg53P2HiB6HnniPKJUfI=; h=Subject:To:From:Date:From; b=wYm24/p5QqRjawYnnJUNrCpc94/MZhKaF2MPxlNHJE8RnKVcDkVyCMYnDymxONKVi y3rqth7Y0+QmniBPAONM40elc0RnZGo6tPvubR22qU4uMaIizwjJROz3cg5hPynSzw AEKzte3712iOSa+qyr8a4Pz8ykKkkRivJRtCReB4= Subject: patch "phy: renesas: rcar-gen3-usb2: Fix sysfs interface of "role"" added to char-misc-next To: yoshihiro.shimoda.uh@renesas.com, geert+renesas@glider.be, kishon@ti.com, pavel@denx.de, stable@vger.kernel.org From: Date: Fri, 08 Nov 2019 08:18:30 +0100 Message-ID: <1573197510190206@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 phy: renesas: rcar-gen3-usb2: Fix sysfs interface of "role" to my char-misc git tree which can be found at git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git in the char-misc-next 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 also be merged in the next major kernel release during the merge window. If you have any questions about this process, please let me know. >From 4bd5ead82d4b877ebe41daf95f28cda53205b039 Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Mon, 7 Oct 2019 16:55:10 +0900 Subject: phy: renesas: rcar-gen3-usb2: 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(). Reported-by: Pavel Machek Fixes: 9bb86777fb71 ("phy: rcar-gen3-usb2: add sysfs for usb role swap") Cc: # v4.10+ Signed-off-by: Yoshihiro Shimoda Reviewed-by: Geert Uytterhoeven Acked-by: Pavel Machek Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/renesas/phy-rcar-gen3-usb2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c index 49ec67d46ccc..bfb22f868857 100644 --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -320,9 +321,9 @@ static ssize_t role_store(struct device *dev, struct device_attribute *attr, if (!ch->is_otg_channel || !rcar_gen3_is_any_rphy_initialized(ch)) return -EIO; - if (!strncmp(buf, "host", strlen("host"))) + if (sysfs_streq(buf, "host")) new_mode = PHY_MODE_USB_HOST; - else if (!strncmp(buf, "peripheral", strlen("peripheral"))) + else if (sysfs_streq(buf, "peripheral")) new_mode = PHY_MODE_USB_DEVICE; else return -EINVAL; -- 2.24.0