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=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 D8DA0C433DF for ; Thu, 14 May 2020 15:19:14 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A5C322065F for ; Thu, 14 May 2020 15:19:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="Z9X6HDKu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5C322065F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 815F827253; Thu, 14 May 2020 15:19:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hpFmYlScZwDy; Thu, 14 May 2020 15:19:07 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id C0E0127085; Thu, 14 May 2020 15:19:05 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 6BB7D1BF37A for ; Thu, 14 May 2020 15:19:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 63C0888AA1 for ; Thu, 14 May 2020 15:19:04 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CYarEHN+FRxP for ; Thu, 14 May 2020 15:18:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from esa3.microchip.iphmx.com (esa3.microchip.iphmx.com [68.232.153.233]) by whitealder.osuosl.org (Postfix) with ESMTPS id AD544884C2 for ; Thu, 14 May 2020 15:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1589469539; x=1621005539; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Rn1pc1QTMgKmish9JgDfo6jrHeq3EAb4tQb+UmggaHs=; b=Z9X6HDKubv5HjUr4pSWKCrVbrVAhmfhKWnuS3ftc8GdfGxG/VCnf+FBb /wqtPNf62Kixm+B5YJtGk0FhGpJoBxvblcHtySh1E+Qr3NHdYpul7Mgjb LVYmJfZu2AbLkvvDmhB4xwzGeTGJ4bbI8fEWDfV4lvhDgwhmw6ahljy4H pjPyIHFaIxPZkpg9Gvt01eMjJL/bvMER6HdKjXntwLuv1CZpiaxASYYwe reqBHaRr9tr7e5eaG36Jh6Ny24UqJAMrf0yKbDM7PIZB5OS00flHvCnLw q6iXrUUZOPG6BqZ36yfAzangR1ygHFJ/jf0iS/CWjk2q9yuwzxSJVjcDH Q==; IronPort-SDR: AF2hbRuxcvisuVT0xf6kLCxQMTs4C5LGJttxc1RUaYUYz0H1dKA2tliybFI3sbnUrNdN+kVUPG EubRSAAQGUUKx70Ty6EZGvMqm5NIJQl/WVgF0wYnSqopo3dx1SYYk45mnb8fmagVYssu8HwhSU QsJI98vJazbkwF5s49ZpFxOO/rIOvgmLQyyBddQz+9DrW7Q3zODtzbrlxxe9+XkojdEozDxh+F jbfMbZA829uWbL4awKIngx7CkEztt6I+gdfO+j8njDiPgXKPuC13QZHRDFvrRmObFyRoe79OwN eJM= X-IronPort-AV: E=Sophos;i="5.73,391,1583218800"; d="scan'208";a="76658375" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 May 2020 08:18:59 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 14 May 2020 08:18:59 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Thu, 14 May 2020 08:19:01 -0700 From: Christian Gromm To: Subject: [PATCH v2 3/7] staging: most: usb: check number of reported endpoints Date: Thu, 14 May 2020 17:18:48 +0200 Message-ID: <1589469532-21488-4-git-send-email-christian.gromm@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589469532-21488-1-git-send-email-christian.gromm@microchip.com> References: <1589469532-21488-1-git-send-email-christian.gromm@microchip.com> MIME-Version: 1.0 X-BeenThere: driverdev-devel@linuxdriverproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Gromm , driverdev-devel@linuxdriverproject.org, linux-usb@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" This patch checks the number of endpoints reported by the USB interface descriptor and throws an error if the number exceeds MAX_NUM_ENDPOINTS. Signed-off-by: Christian Gromm Reported-by: Greg Kroah-Hartman --- v2: drivers/staging/most/usb/usb.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c index dbb6003..d5c73cb 100644 --- a/drivers/staging/most/usb/usb.c +++ b/drivers/staging/most/usb/usb.c @@ -950,13 +950,17 @@ hdm_probe(struct usb_interface *interface, const struct usb_device_id *id) unsigned int num_endpoints; struct most_channel_capability *tmp_cap; struct usb_endpoint_descriptor *ep_desc; - int ret = 0; + int ret; if (!mdev) - goto err_out_of_memory; + return -ENOMEM; usb_set_intfdata(interface, mdev); num_endpoints = usb_iface_desc->desc.bNumEndpoints; + if (num_endpoints > MAX_NUM_ENDPOINTS) { + kfree(mdev); + return -EINVAL; + } mutex_init(&mdev->io_mutex); INIT_WORK(&mdev->poll_work_obj, wq_netinfo); timer_setup(&mdev->link_stat_timer, link_stat_timer_handler, 0); @@ -1085,11 +1089,6 @@ hdm_probe(struct usb_interface *interface, const struct usb_device_id *id) kfree(mdev->conf); err_free_mdev: put_device(&mdev->dev); -err_out_of_memory: - if (ret == 0 || ret == -ENOMEM) { - ret = -ENOMEM; - dev_err(dev, "out of memory\n"); - } return ret; } -- 2.7.4 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel