From patchwork Thu Jan 21 10:29:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12035509 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=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 EFEF2C433E0 for ; Thu, 21 Jan 2021 10:32:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 994D823433 for ; Thu, 21 Jan 2021 10:32:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729315AbhAUKbn (ORCPT ); Thu, 21 Jan 2021 05:31:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:60232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729292AbhAUKbU (ORCPT ); Thu, 21 Jan 2021 05:31:20 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2389C23444; Thu, 21 Jan 2021 10:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611224971; bh=2a6eKV6ka6kZEf6Ox3YKBGQDv8NFUC/2/V+O9Rj3yJw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=buEQiFy0gZ+L5hd7cfuwohcx24LtrMGVQQfepETEvvJlcepVS7a/MfkMWGWMJ+rkV GmS0q4GQzqyO9zeevbshnQ1sN2LUvER/3FvaSOmBSH3+lqe7LmcZ5zFlUPGRQe1KZ7 K5zLdFHjfD8N8NaWH9gwnd3e95O53MLEGuFMdnbVsatOGNJgV5kjvK8vlC6UAx0nyT V3OdmY9NF7g8yy05VrJrIg1V4QQm9+VZZ0YP0KyB0neSOWpt2dDah8qFpcHadAQcsX +IpAI7ezdqY29SfL8MDZtHXThPNaOkbKUqpWmMJp/MXvNB81r++rcDo0K9gZ3kHmV9 Z1aFj5o+NAoaw== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1l2XDc-0004YH-I2; Thu, 21 Jan 2021 11:29:36 +0100 From: Johan Hovold To: linux-usb@vger.kernel.org Cc: Manivannan Sadhasivam , linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 01/10] USB: serial: xr: fix NULL-deref at probe Date: Thu, 21 Jan 2021 11:29:13 +0100 Message-Id: <20210121102922.17439-3-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210121102922.17439-1-johan@kernel.org> References: <20210121102922.17439-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Make sure that the probed device has an interface 0 to avoid dereferencing a NULL pointer in case of a malicious device or during USB-descriptor fuzzing. Fixes: a8f54b7bd132 ("USB: serial: add MaxLinear/Exar USB to Serial driver") Signed-off-by: Johan Hovold --- drivers/usb/serial/xr_serial.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/serial/xr_serial.c b/drivers/usb/serial/xr_serial.c index bdb2df27b50b..7be6da6a5cf3 100644 --- a/drivers/usb/serial/xr_serial.c +++ b/drivers/usb/serial/xr_serial.c @@ -552,6 +552,9 @@ static int xr_probe(struct usb_serial *serial, const struct usb_device_id *id) /* But claim the control interface during data interface probe */ control_interface = usb_ifnum_to_if(usb_dev, 0); + if (!control_interface) + return -ENODEV; + ret = usb_driver_claim_interface(driver, control_interface, NULL); if (ret) { dev_err(&serial->interface->dev, "Failed to claim control interface\n");