[Suggestion] drivers/usb/core: for u16, use stack allocation instead of kmalloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Greg Kroah-Hartman:

in drivers/usb/core/message.c:
  at line 943, status is kmalloc ( sizeof u16 )
  at line 952, assign the value of status to data
  at line 953, free status.

  it is better to let "u16 status" instead of "u16 *status = kmalloc...".


  thanks.

gchen.

 940 int usb_get_status(struct usb_device *dev, int type, int target, void *data)
 941 {
 942         int ret;
 943         u16 *status = kmalloc(sizeof(*status), GFP_KERNEL);
 944 
 945         if (!status)
 946                 return -ENOMEM;
 947 
 948         ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
 949                 USB_REQ_GET_STATUS, USB_DIR_IN | type, 0, target, status,
 950                 sizeof(*status), USB_CTRL_GET_TIMEOUT);
 951 
 952         *(u16 *)data = *status;
 953         kfree(status);
 954         return ret;
 955 }
 956 EXPORT_SYMBOL_GPL(usb_get_status);
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux