Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp834363pxb; Tue, 3 Nov 2020 13:54:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJyE2smt8BmmYT2vrww4uAbiomyaBmy6hr4dYaDcrITPUiZPPloSrXQiwHFk+8/WW+qC/Uaw X-Received: by 2002:a05:6402:31b6:: with SMTP id dj22mr8564899edb.348.1604440485714; Tue, 03 Nov 2020 13:54:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604440485; cv=none; d=google.com; s=arc-20160816; b=upx4fsACYyG+c3lATuiQOecuGd97792Ddu/WEMakSzOHEXZGpblN09SEpfY6DgrFmK Ik5ir7jgqabwQJt54xTv/S97vLqux84VzCzcr0XzQoMrcHsoQPbwS4cczcaN1Yrl+D7p pU2w867HlVEAyEDTlZ5Vzgt9gbPNfcRBsNizTG1xkh5OBvtky8aj+9MY4YkjI8vg3lA+ 0HxBk8RshhTlSAdTyxBR7DJ4SN8jz3Jwtva3O1pYWFtkXr7wi0bICLKTOH/110vAEAmd PYTbFrdWPwh3yOIy/CES7KHEyaAU6ZzUnymL++kaoL8JAQ76f3cNWdjYdjRLrfWOU5S+ La5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NTrlw3QI+37VN+OvifVOxsN0lc6aO7bnc/LNDiq7zEo=; b=03/NG8JZv8c6pfsf4225f0SIZ8auq3P7wgSXCxGsafnVaFSYmHytDkSd2cixWhId1t 3c0kR2XEgbzfnjQ0rD1+lOkG2zMZtvsUJJNq9ug3ArsKgS8zzTW6q9U8erP2ph1nzJIQ WN4ntHj1sUReWaExF6ia5JSCTQHUAblfjER+gMDiY2YDmuxoCeGa1KsTA8bOytMwjigZ 46kLkD+4ak5B9xIVn6KD/0gtm2elIcCWWkKHBeHy91n1pqWRGjiYdG8tRh+y4dO43o7T 6k1Eg9EPcnzQqFDaQno4cN3V3LdT2l0EMVlMbIdWc4gDO3URvyMnDFRracLTKSFmmt3I jqVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e1A8tPcJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y18si89193ejb.408.2020.11.03.13.54.22; Tue, 03 Nov 2020 13:54:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e1A8tPcJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730827AbgKCUr1 (ORCPT + 99 others); Tue, 3 Nov 2020 15:47:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:37750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730127AbgKCUrZ (ORCPT ); Tue, 3 Nov 2020 15:47:25 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 74AC7223FD; Tue, 3 Nov 2020 20:47:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436444; bh=xXW6lvY6PaBRATMkfm5HyvrMwBlEn47zbSQ9JAX5Uus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e1A8tPcJ2PXPv/PGbfS62X0EoOPc6umvW8dXvtPuhrmYVJSpr6AQ1qVqYkMD9MpyY POGhGQlPyAjbpJ6XpYmImYzjiW/TeKuG2DyWr/gLEERwiLVfdGRnCzoEGvQHJ9AUNt 9znsAHdeBTbNSKaXxdLnt/9oTW/PoPoybsvXQDkU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Pany , Bastien Nocera , "M. Vefa Bicakci" Subject: [PATCH 5.9 252/391] USB: apple-mfi-fastcharge: dont probe unhandled devices Date: Tue, 3 Nov 2020 21:35:03 +0100 Message-Id: <20201103203404.022427295@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bastien Nocera commit 0cb686692fd200db12dcfb8231e793c1c98aec41 upstream. From: Bastien Nocera Contrary to the comment above the id table, we didn't implement a match function. This meant that every single Apple device that was already plugged in to the computer would have its device driver reprobed when the apple-mfi-fastcharge driver was loaded, eg. the SD card reader could be reprobed when the apple-mfi-fastcharge after pivoting root during boot up and the module became available. Make sure that the driver probe isn't being run for unsupported devices by adding a match function that checks the product ID, in addition to the id_table checking the vendor ID. Link: https://bugzilla.redhat.com/show_bug.cgi?id=1878347 Link: https://lore.kernel.org/linux-usb/CAE3RAxt0WhBEz8zkHrVO5RiyEOasayy1QUAjsv-pB0fAbY1GSw@mail.gmail.com/ Fixes: 249fa8217b84 ("USB: Add driver to control USB fast charge for iOS devices") Cc: # 5.8 Cc: Greg Kroah-Hartman Cc: Alan Stern [m.v.b: Add Link and Reported-by tags to the commit message] Reported-by: Pany Tested-by: Pan (Pany) YUAN Tested-by: Bastien Nocera Signed-off-by: Bastien Nocera Signed-off-by: M. Vefa Bicakci Link: https://lore.kernel.org/r/20201022135521.375211-3-m.v.b@runbox.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/apple-mfi-fastcharge.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) --- a/drivers/usb/misc/apple-mfi-fastcharge.c +++ b/drivers/usb/misc/apple-mfi-fastcharge.c @@ -163,17 +163,23 @@ static const struct power_supply_desc ap .property_is_writeable = apple_mfi_fc_property_is_writeable }; +static bool mfi_fc_match(struct usb_device *udev) +{ + int idProduct; + + idProduct = le16_to_cpu(udev->descriptor.idProduct); + /* See comment above mfi_fc_id_table[] */ + return (idProduct >= 0x1200 && idProduct <= 0x12ff); +} + static int mfi_fc_probe(struct usb_device *udev) { struct power_supply_config battery_cfg = {}; struct mfi_device *mfi = NULL; - int err, idProduct; + int err; - idProduct = le16_to_cpu(udev->descriptor.idProduct); - /* See comment above mfi_fc_id_table[] */ - if (idProduct < 0x1200 || idProduct > 0x12ff) { + if (!mfi_fc_match(udev)) return -ENODEV; - } mfi = kzalloc(sizeof(struct mfi_device), GFP_KERNEL); if (!mfi) { @@ -220,6 +226,7 @@ static struct usb_device_driver mfi_fc_d .probe = mfi_fc_probe, .disconnect = mfi_fc_disconnect, .id_table = mfi_fc_id_table, + .match = mfi_fc_match, .generic_subclass = 1, };