@@ -258,7 +258,7 @@ static int gs_cmd_reset(struct gs_usb *gsusb, struct gs_can *gsdev)
258
258
rc = usb_control_msg (interface_to_usbdev (intf ),
259
259
usb_sndctrlpipe (interface_to_usbdev (intf ), 0 ),
260
260
GS_USB_BREQ_MODE ,
261
- USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE ,
261
+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE ,
262
262
gsdev -> channel ,
263
263
0 ,
264
264
dm ,
@@ -432,7 +432,7 @@ static int gs_usb_set_bittiming(struct net_device *netdev)
432
432
rc = usb_control_msg (interface_to_usbdev (intf ),
433
433
usb_sndctrlpipe (interface_to_usbdev (intf ), 0 ),
434
434
GS_USB_BREQ_BITTIMING ,
435
- USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE ,
435
+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE ,
436
436
dev -> channel ,
437
437
0 ,
438
438
dbt ,
@@ -546,7 +546,6 @@ static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb,
546
546
hf ,
547
547
urb -> transfer_dma );
548
548
549
-
550
549
if (rc == - ENODEV ) {
551
550
netif_device_detach (netdev );
552
551
} else {
@@ -804,7 +803,7 @@ static struct gs_can *gs_make_candev(unsigned int channel,
804
803
rc = usb_control_msg (interface_to_usbdev (intf ),
805
804
usb_rcvctrlpipe (interface_to_usbdev (intf ), 0 ),
806
805
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 ,
808
807
channel ,
809
808
0 ,
810
809
bt_const ,
@@ -908,57 +907,72 @@ static int gs_usb_probe(struct usb_interface *intf,
908
907
struct gs_usb * dev ;
909
908
int rc = - ENOMEM ;
910
909
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 ;
915
918
916
919
/* send host config */
917
920
rc = usb_control_msg (interface_to_usbdev (intf ),
918
921
usb_sndctrlpipe (interface_to_usbdev (intf ), 0 ),
919
922
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 ,
921
924
1 ,
922
925
intf -> altsetting [0 ].desc .bInterfaceNumber ,
923
- & hconf ,
924
- sizeof (hconf ),
926
+ hconf ,
927
+ sizeof (* hconf ),
925
928
1000 );
926
929
930
+ kfree (hconf );
931
+
927
932
if (rc < 0 ) {
928
933
dev_err (& intf -> dev , "Couldn't send data format (err=%d)\n" ,
929
934
rc );
930
935
return rc ;
931
936
}
932
937
938
+ dconf = kmalloc (sizeof (* dconf ), GFP_KERNEL );
939
+ if (!dconf )
940
+ return - ENOMEM ;
941
+
933
942
/* read device config */
934
943
rc = usb_control_msg (interface_to_usbdev (intf ),
935
944
usb_rcvctrlpipe (interface_to_usbdev (intf ), 0 ),
936
945
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 ,
938
947
1 ,
939
948
intf -> altsetting [0 ].desc .bInterfaceNumber ,
940
- & dconf ,
941
- sizeof (dconf ),
949
+ dconf ,
950
+ sizeof (* dconf ),
942
951
1000 );
943
952
if (rc < 0 ) {
944
953
dev_err (& intf -> dev , "Couldn't get device config: (err=%d)\n" ,
945
954
rc );
955
+ kfree (dconf );
946
956
return rc ;
947
957
}
948
958
949
- icount = dconf . icount + 1 ;
959
+ icount = dconf -> icount + 1 ;
950
960
dev_info (& intf -> dev , "Configuring for %d interfaces\n" , icount );
951
961
952
962
if (icount > GS_MAX_INTF ) {
953
963
dev_err (& intf -> dev ,
954
964
"Driver cannot handle more that %d CAN interfaces\n" ,
955
965
GS_MAX_INTF );
966
+ kfree (dconf );
956
967
return - EINVAL ;
957
968
}
958
969
959
970
dev = kzalloc (sizeof (* dev ), GFP_KERNEL );
960
- if (!dev )
971
+ if (!dev ) {
972
+ kfree (dconf );
961
973
return - ENOMEM ;
974
+ }
975
+
962
976
init_usb_anchor (& dev -> rx_submitted );
963
977
964
978
atomic_set (& dev -> active_channels , 0 );
@@ -967,7 +981,7 @@ static int gs_usb_probe(struct usb_interface *intf,
967
981
dev -> udev = interface_to_usbdev (intf );
968
982
969
983
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 );
971
985
if (IS_ERR_OR_NULL (dev -> canch [i ])) {
972
986
/* save error code to return later */
973
987
rc = PTR_ERR (dev -> canch [i ]);
@@ -978,12 +992,15 @@ static int gs_usb_probe(struct usb_interface *intf,
978
992
gs_destroy_candev (dev -> canch [i ]);
979
993
980
994
usb_kill_anchored_urbs (& dev -> rx_submitted );
995
+ kfree (dconf );
981
996
kfree (dev );
982
997
return rc ;
983
998
}
984
999
dev -> canch [i ]-> parent = dev ;
985
1000
}
986
1001
1002
+ kfree (dconf );
1003
+
987
1004
return 0 ;
988
1005
}
989
1006
0 commit comments