From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796526031; b=OW9y1vmun/jOcgA8RpMw0qnfs05XR4PF6lww0gQqMZE+zqkioBizm7YVOES2y2j2cMtx 6nsCddmyHjPRbKlaIHqIgTbeyuLCTpLjYSvAYgV30iaHe9w7CoEvyKGpmFsKJgszuvTR7 UQoMzm2FIVLGGJ8r85Z4b3NEVqLM3ZnzcTizQf1HQKggpGdC9SlLwU9rqrqIw0bHsM6/p TbYorORrd9bI84N2eR4zFISmzAaxjw7XQJRI5cCnoYxtRuyN24zrLYqBNaNNWx0Hos028 h+pmfbG83yvvqXawOg33lPpniSVjMpVMpZG0j5DduB3+x2PQEptgZGdMaA7+xO4IESA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796526031; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=hcwan6GU0y0h5r8WwY1Lfrm5Lotw2A0M/blCiOrxL30=; b=Gqv6uOSKGJPZM3AD0wxzI2/SK3tYFTb+7Q1yBQLLbDDy/s3tfRwFURQJ66SMxAHpaqWg 0OU8n+hgcXIQ6PrGevzu1Dy6KRlSVjOnNZhIy+yZhLa5kMWyYpqa7bPxpvKE7VNp7C6PE 0zOpD6yNFgCRQXEmAuTVmeFp+39HakP7e8V62eKnIB01nWJMh53cLUdQ+WRfKxQiRCAGw eVnJdUhRIoouGtbh277m8eIXNI6cZ4lxiiYeNCg4nDoZOYiD6m/qo5jW672EadsEOmPEu j5QlPouy8dOIYdaWUm10/yes5zwWcKUXoDW+GnY25Vsm6A0WBjUMN/fy40UbP7eRtQQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PoBtU7Gw; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEF33606A31F for ; Sun, 6 Dec 2026 03:00:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PoBtU7Gw Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39FE41F0092B; Sun, 6 Dec 2026 03:00:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796526031; bh=hcwan6GU0y0h5r8WwY1Lfrm5Lotw2A0M/blCiOrxL30=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=PoBtU7Gw5BxwqvyCPbV016HevFqSIEbTuN1jvMC7kaEvOkKSvQJhkhMLDoLt/s1bh Mi9aVaOIS2zwnMXMCKIxpGMMVb//oNHlDhdPkXi87rP7RApCqFRhcJxWBOng5vZjGc Hox7jeHCRJYeHAKBTLPoMWUPlt5EJkTCUGM7HHs9aE6cxfZPaWkuN0bn5jKg+UcFWF HKrKDxQ6cYco3XfAwgDAFz4a1iOYnCGGyk6DRAAj/0rl+48R6rhpIvViHDND6duATI wdqMAUpc6XHk0ngeignxjyCvjgYp1PrDiPVoafq3Mgo46hErs8SYH7/KHPFLK27Hdn wJPc6MNDpS98w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 01/12] usb: apple-mfi-fastcharge: Convert to devm resources Reply-To: sashiko-reviews@lists.linux.dev To: "Rosen Penev" Cc: linux-usb@vger.kernel.org In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 06 Dec 2026 03:00:30 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] usb: apple-mfi-fastcharge: devm power supply unregister races with USB unbind - [Medium] usb: apple-mfi-fastcharge: commit message describes absent module init fix - [Low] usb: apple-mfi-fastcharge: stale comment still mentions .probe() ID check -- commit 427d84edebb61420afc7208c728895fb30a00bfa Author: Rosen Penev usb: apple-mfi-fastcharge: Convert to devm resources This commit converts apple-mfi-fastcharge to device-managed allocations and power supply registration, removes mfi_fc_disconnect(), and drops the mfi_fc_match() call from mfi_fc_probe(). > Also fix the module init/exit: module_usb_driver() is for struct > usb_driver *, not struct usb_device_driver *. Use the correct > usb_register_device_driver() / usb_deregister_device_driver() calls > instead. [Severity: Medium] Should this paragraph be dropped from the commit message? mfi_fc_driver_init() and mfi_fc_driver_exit() already call usb_register_device_driver() and usb_deregister_device_driver(), and this patch does not touch them. Separately, the patch moves mfi->udev =3D udev before power supply registration and drops the dev_err() on registration failure without mentioning either change in the changelog. > diff --git a/drivers/usb/misc/apple-mfi-fastcharge.c b/drivers/usb/misc/a= pple-mfi-fastcharge.c > index 02adec28d9e69..133dde848dd12 100644 > --- a/drivers/usb/misc/apple-mfi-fastcharge.c > +++ b/drivers/usb/misc/apple-mfi-fastcharge.c [ ... ] > @@ -177,67 +166,42 @@ static int mfi_fc_probe(struct usb_device *udev) > { > struct power_supply_config battery_cfg =3D {}; > - struct mfi_device *mfi =3D NULL; > - char *battery_name; > - int err; > - > - if (!mfi_fc_match(udev)) > - return -ENODEV; [Severity: Low] With mfi_fc_match() removed from mfi_fc_probe(), the comment above mfi_fc_id_table[] still says "Those checks will be done in .match() and .probe()." Should that comment be updated? [ ... ] > + battery =3D devm_power_supply_register(&udev->dev, battery_desc, &batte= ry_cfg); > + if (IS_ERR(battery)) > + return PTR_ERR(battery); > =20 > -static void mfi_fc_disconnect(struct usb_device *udev) > -{ > - struct mfi_device *mfi; > - > - mfi =3D dev_get_drvdata(&udev->dev); > - if (mfi->battery) > - power_supply_unregister(mfi->battery); > - kfree(mfi->battery_desc.name); > - dev_set_drvdata(&udev->dev, NULL); > - kfree(mfi); > + return 0; > } > =20 > static struct usb_device_driver mfi_fc_driver =3D { > .name =3D "apple-mfi-fastcharge", > .probe =3D mfi_fc_probe, > - .disconnect =3D mfi_fc_disconnect, [Severity: Medium] Can switching to devm_power_supply_register() and removing mfi_fc_disconnect() race with a concurrent sysfs write to charge_type during USB unbind? __device_release_driver() runs device_remove() before device_unbind_cleanup(). Because mfi_fc_driver has no .disconnect callback now, usb_unbind_device() runs usb_generic_driver_disconnect() and usb_autosuspend_device() while the power supply is still registered: CPU0 CPU1 __device_release_driver() device_lock(&udev->dev) usb_unbind_device() usb_generic_driver_disconnect() usb_set_configuration(..., -1) usb_autosuspend_device() apple_mfi_fc_set_property() pm_runtime_get_sync(&udev->dev) usb_runtime_resume() <-- no device_lo= ck usb_control_msg(...) <-- unconfigured device_unbind_cleanup() power_supply_unregister() A concurrent write to charge_type during rmmod or sysfs unbind can submit vendor control request 0x40 to an unconfigured device or trigger usb_runtime_resume() -> usb_resume_both() -> finish_port_resume() without holding device_lock(&udev->dev) while unbind holds it. Keeping mfi_fc_disconnect() to call power_supply_unregister() synchronously before usb_generic_driver_disconnect() runs avoids this window. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796524906.gi= t.rosenp@gmail.com?part=3D1