From patchwork Wed Jan 22 09:28:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 233391 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=-5.7 required=3.0 tests=DATE_IN_PAST_03_06, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable 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 BD929C33CAF for ; Wed, 22 Jan 2020 13:27:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 866E02468C for ; Wed, 22 Jan 2020 13:27:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699624; bh=8MLR2a1b0otidC3PFFMbXz7apW9xfuUu1E1XAiOutQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=RX5aKAx8zhy13ObAIo8l0qBIkfnJh/+lsdyz5F8z5Pf1/TlrTgFK1Ntal1TR2WO6d Upz55FhMQu3Qy76Lo3fNJUS7VOSzW24q+eQsPHNd40gXOOEvqWSrBSDLPyJ3ZNkXmt t62xyV5h2X9RQj7HN9qTpKx0KqMi33MD0bhTVVzc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731669AbgAVN0s (ORCPT ); Wed, 22 Jan 2020 08:26:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:47842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731301AbgAVN0r (ORCPT ); Wed, 22 Jan 2020 08:26:47 -0500 Received: from localhost (unknown [84.241.205.26]) (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 6800B24685; Wed, 22 Jan 2020 13:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699607; bh=8MLR2a1b0otidC3PFFMbXz7apW9xfuUu1E1XAiOutQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZEv6YYrntwwNP8RjnZtCOmX1DlWnYbQXT+kQUMXXZlcX1tYu/yIDIerspobNAEVdm kxYQNeYPPTL0i2+Mg7nO1ZgeJbZU1/dFAbNMPG3G67woJLV1T7Z7TX0r55lwkOWPdG IgCruMi7lkMTAkwSMlaOtJNz3pnxioQfTbEIx7Vw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, hayeswang , Johan Hovold , "David S. Miller" Subject: [PATCH 5.4 147/222] r8152: add missing endpoint sanity check Date: Wed, 22 Jan 2020 10:28:53 +0100 Message-Id: <20200122092844.254085651@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Johan Hovold [ Upstream commit 86f3f4cd53707ceeec079b83205c8d3c756eca93 ] Add missing endpoint sanity check to probe in order to prevent a NULL-pointer dereference (or slab out-of-bounds access) when retrieving the interrupt-endpoint bInterval on ndo_open() in case a device lacks the expected endpoints. Fixes: 40a82917b1d3 ("net/usb/r8152: enable interrupt transfer") Cc: hayeswang Signed-off-by: Johan Hovold Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/usb/r8152.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -5587,6 +5587,9 @@ static int rtl8152_probe(struct usb_inte return -ENODEV; } + if (intf->cur_altsetting->desc.bNumEndpoints < 3) + return -ENODEV; + usb_reset_device(udev); netdev = alloc_etherdev(sizeof(struct r8152)); if (!netdev) {