Linux USB
 help / color / mirror / Atom feed
* [PATCH v1] usb: typec: Fix arg check for usb_power_delivery_unregister_capabilities
@ 2024-09-19  7:58 Amit Sunil Dhamne
  2024-09-19  8:11 ` Greg KH
  2024-09-19  8:51 ` Dmitry Baryshkov
  0 siblings, 2 replies; 5+ messages in thread
From: Amit Sunil Dhamne @ 2024-09-19  7:58 UTC (permalink / raw)
  To: gregkh, heikki.krogerus
  Cc: badhri, kyletso, rdbabiera, linux-kernel, linux-usb,
	Amit Sunil Dhamne, stable

usb_power_delivery_register_capabilities() returns ERR_PTR in case of
failure. usb_power_delivery_unregister_capabilities() we only check
argument ("cap") for NULL. A more robust check would be checking for
ERR_PTR as well.

Cc: stable@vger.kernel.org
Fixes: 662a60102c12 ("usb: typec: Separate USB Power Delivery from USB Type-C")
Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
Reviewed-by: Badhri Jagan Sridharan <badhri@google.com>
---
 drivers/usb/typec/pd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/pd.c b/drivers/usb/typec/pd.c
index d78c04a421bc..761fe4dddf1b 100644
--- a/drivers/usb/typec/pd.c
+++ b/drivers/usb/typec/pd.c
@@ -519,7 +519,7 @@ EXPORT_SYMBOL_GPL(usb_power_delivery_register_capabilities);
  */
 void usb_power_delivery_unregister_capabilities(struct usb_power_delivery_capabilities *cap)
 {
-	if (!cap)
+	if (IS_ERR_OR_NULL(cap))
 		return;
 
 	device_for_each_child(&cap->dev, NULL, remove_pdo);

base-commit: 68d4209158f43a558c5553ea95ab0c8975eab18c
-- 
2.46.0.792.g87dc391469-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-09-19 22:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-19  7:58 [PATCH v1] usb: typec: Fix arg check for usb_power_delivery_unregister_capabilities Amit Sunil Dhamne
2024-09-19  8:11 ` Greg KH
2024-09-19 10:03   ` Dmitry Baryshkov
2024-09-19 22:50     ` Amit Sunil Dhamne
2024-09-19  8:51 ` Dmitry Baryshkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox