[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <gkyzytmvcaefbfvu6ryss7zq5cm3t3mcjgtugsryhxl7aglpkk@gi2fgjnyidgi>
Date: Thu, 19 Sep 2024 13:03:20 +0300
From: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
To: Greg KH <gregkh@...uxfoundation.org>
Cc: Amit Sunil Dhamne <amitsd@...gle.com>, heikki.krogerus@...ux.intel.com,
badhri@...gle.com, kyletso@...gle.com, rdbabiera@...gle.com,
linux-kernel@...r.kernel.org, linux-usb@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH v1] usb: typec: Fix arg check for
usb_power_delivery_unregister_capabilities
On Thu, Sep 19, 2024 at 10:11:37AM GMT, Greg KH wrote:
> On Thu, Sep 19, 2024 at 12:58:12AM -0700, Amit Sunil Dhamne wrote:
> > 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@...r.kernel.org
> > Fixes: 662a60102c12 ("usb: typec: Separate USB Power Delivery from USB Type-C")
> > Signed-off-by: Amit Sunil Dhamne <amitsd@...gle.com>
> > Reviewed-by: Badhri Jagan Sridharan <badhri@...gle.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))
>
> This feels like there's a wrong caller, why would this be called with an
> error value in the first place? Why not fix that? And why would this
> be called with NULL as well in the first place?
I think passing NULL matches the rest of the kernel, it removes
unnecessary if(!NULL) statements from the caller side.
--
With best wishes
Dmitry
Powered by blists - more mailing lists