@@ -258,7 +258,7 @@ static int gs_cmd_reset(struct gs_usb *gsusb, struct gs_can *gsdev)
258258 rc = usb_control_msg (interface_to_usbdev (intf ),
259259 usb_sndctrlpipe (interface_to_usbdev (intf ), 0 ),
260260 GS_USB_BREQ_MODE ,
261- USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE ,
261+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE ,
262262 gsdev -> channel ,
263263 0 ,
264264 dm ,
@@ -432,7 +432,7 @@ static int gs_usb_set_bittiming(struct net_device *netdev)
432432 rc = usb_control_msg (interface_to_usbdev (intf ),
433433 usb_sndctrlpipe (interface_to_usbdev (intf ), 0 ),
434434 GS_USB_BREQ_BITTIMING ,
435- USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE ,
435+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE ,
436436 dev -> channel ,
437437 0 ,
438438 dbt ,
@@ -546,7 +546,6 @@ static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb,
546546 hf ,
547547 urb -> transfer_dma );
548548
549-
550549 if (rc == - ENODEV ) {
551550 netif_device_detach (netdev );
552551 } else {
@@ -804,7 +803,7 @@ static struct gs_can *gs_make_candev(unsigned int channel,
804803 rc = usb_control_msg (interface_to_usbdev (intf ),
805804 usb_rcvctrlpipe (interface_to_usbdev (intf ), 0 ),
806805 GS_USB_BREQ_BT_CONST ,
807- USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE ,
806+ USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE ,
808807 channel ,
809808 0 ,
810809 bt_const ,
@@ -908,57 +907,72 @@ static int gs_usb_probe(struct usb_interface *intf,
908907 struct gs_usb * dev ;
909908 int rc = - ENOMEM ;
910909 unsigned int icount , i ;
911- struct gs_host_config hconf = {
912- .byte_order = 0x0000beef ,
913- };
914- struct gs_device_config dconf ;
910+ struct gs_host_config * hconf ;
911+ struct gs_device_config * dconf ;
912+
913+ hconf = kmalloc (sizeof (* hconf ), GFP_KERNEL );
914+ if (!hconf )
915+ return - ENOMEM ;
916+
917+ hconf -> byte_order = 0x0000beef ;
915918
916919 /* send host config */
917920 rc = usb_control_msg (interface_to_usbdev (intf ),
918921 usb_sndctrlpipe (interface_to_usbdev (intf ), 0 ),
919922 GS_USB_BREQ_HOST_FORMAT ,
920- USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE ,
923+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE ,
921924 1 ,
922925 intf -> altsetting [0 ].desc .bInterfaceNumber ,
923- & hconf ,
924- sizeof (hconf ),
926+ hconf ,
927+ sizeof (* hconf ),
925928 1000 );
926929
930+ kfree (hconf );
931+
927932 if (rc < 0 ) {
928933 dev_err (& intf -> dev , "Couldn't send data format (err=%d)\n" ,
929934 rc );
930935 return rc ;
931936 }
932937
938+ dconf = kmalloc (sizeof (* dconf ), GFP_KERNEL );
939+ if (!dconf )
940+ return - ENOMEM ;
941+
933942 /* read device config */
934943 rc = usb_control_msg (interface_to_usbdev (intf ),
935944 usb_rcvctrlpipe (interface_to_usbdev (intf ), 0 ),
936945 GS_USB_BREQ_DEVICE_CONFIG ,
937- USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE ,
946+ USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE ,
938947 1 ,
939948 intf -> altsetting [0 ].desc .bInterfaceNumber ,
940- & dconf ,
941- sizeof (dconf ),
949+ dconf ,
950+ sizeof (* dconf ),
942951 1000 );
943952 if (rc < 0 ) {
944953 dev_err (& intf -> dev , "Couldn't get device config: (err=%d)\n" ,
945954 rc );
955+ kfree (dconf );
946956 return rc ;
947957 }
948958
949- icount = dconf . icount + 1 ;
959+ icount = dconf -> icount + 1 ;
950960 dev_info (& intf -> dev , "Configuring for %d interfaces\n" , icount );
951961
952962 if (icount > GS_MAX_INTF ) {
953963 dev_err (& intf -> dev ,
954964 "Driver cannot handle more that %d CAN interfaces\n" ,
955965 GS_MAX_INTF );
966+ kfree (dconf );
956967 return - EINVAL ;
957968 }
958969
959970 dev = kzalloc (sizeof (* dev ), GFP_KERNEL );
960- if (!dev )
971+ if (!dev ) {
972+ kfree (dconf );
961973 return - ENOMEM ;
974+ }
975+
962976 init_usb_anchor (& dev -> rx_submitted );
963977
964978 atomic_set (& dev -> active_channels , 0 );
@@ -967,7 +981,7 @@ static int gs_usb_probe(struct usb_interface *intf,
967981 dev -> udev = interface_to_usbdev (intf );
968982
969983 for (i = 0 ; i < icount ; i ++ ) {
970- dev -> canch [i ] = gs_make_candev (i , intf , & dconf );
984+ dev -> canch [i ] = gs_make_candev (i , intf , dconf );
971985 if (IS_ERR_OR_NULL (dev -> canch [i ])) {
972986 /* save error code to return later */
973987 rc = PTR_ERR (dev -> canch [i ]);
@@ -978,12 +992,15 @@ static int gs_usb_probe(struct usb_interface *intf,
978992 gs_destroy_candev (dev -> canch [i ]);
979993
980994 usb_kill_anchored_urbs (& dev -> rx_submitted );
995+ kfree (dconf );
981996 kfree (dev );
982997 return rc ;
983998 }
984999 dev -> canch [i ]-> parent = dev ;
9851000 }
9861001
1002+ kfree (dconf );
1003+
9871004 return 0 ;
9881005}
9891006
0 commit comments