mirror of https://github.com/torvalds/linux.git
usb: fhci: use kzalloc_flex for priv struct
Convert kzalloc_obj(s) to kzalloc_flex to save an allocation. Add __counted_by to get extra runtime analysis. Move counting variable assignment immediately after allocation as required by __counted_by. Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: https://patch.msgid.link/20260313003456.124270-1-rosenp@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
341434a444
commit
03cd4fd620
|
|
@ -426,16 +426,11 @@ static int fhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
|
|||
}
|
||||
|
||||
/* allocate the private part of the URB */
|
||||
urb_priv = kzalloc_obj(*urb_priv, mem_flags);
|
||||
urb_priv = kzalloc_flex(*urb_priv, tds, size, mem_flags);
|
||||
if (!urb_priv)
|
||||
return -ENOMEM;
|
||||
|
||||
/* allocate the private part of the URB */
|
||||
urb_priv->tds = kzalloc_objs(*urb_priv->tds, size, mem_flags);
|
||||
if (!urb_priv->tds) {
|
||||
kfree(urb_priv);
|
||||
return -ENOMEM;
|
||||
}
|
||||
urb_priv->num_of_tds = size;
|
||||
|
||||
spin_lock_irqsave(&fhci->lock, flags);
|
||||
|
||||
|
|
@ -444,8 +439,6 @@ static int fhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
|
|||
goto err;
|
||||
|
||||
/* fill the private part of the URB */
|
||||
urb_priv->num_of_tds = size;
|
||||
|
||||
urb->status = -EINPROGRESS;
|
||||
urb->actual_length = 0;
|
||||
urb->error_count = 0;
|
||||
|
|
@ -453,10 +446,8 @@ static int fhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
|
|||
|
||||
fhci_queue_urb(fhci, urb);
|
||||
err:
|
||||
if (ret) {
|
||||
kfree(urb_priv->tds);
|
||||
if (ret)
|
||||
kfree(urb_priv);
|
||||
}
|
||||
spin_unlock_irqrestore(&fhci->lock, flags);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -387,9 +387,10 @@ struct urb_priv {
|
|||
int tds_cnt;
|
||||
int state;
|
||||
|
||||
struct td **tds;
|
||||
struct ed *ed;
|
||||
struct timer_list time_out;
|
||||
|
||||
struct td *tds[] __counted_by(num_of_tds);
|
||||
};
|
||||
|
||||
struct endpoint {
|
||||
|
|
|
|||
Loading…
Reference in New Issue