hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/net/can/bcm.c
....@@ -936,6 +936,8 @@
936936
937937 cf = op->frames + op->cfsiz * i;
938938 err = memcpy_from_msg((u8 *)cf, msg, op->cfsiz);
939
+ if (err < 0)
940
+ goto free_op;
939941
940942 if (op->flags & CAN_FD_FRAME) {
941943 if (cf->len > 64)
....@@ -945,12 +947,8 @@
945947 err = -EINVAL;
946948 }
947949
948
- if (err < 0) {
949
- if (op->frames != &op->sframe)
950
- kfree(op->frames);
951
- kfree(op);
952
- return err;
953
- }
950
+ if (err < 0)
951
+ goto free_op;
954952
955953 if (msg_head->flags & TX_CP_CAN_ID) {
956954 /* copy can_id into frame */
....@@ -1021,6 +1019,12 @@
10211019 bcm_tx_start_timer(op);
10221020
10231021 return msg_head->nframes * op->cfsiz + MHSIZ;
1022
+
1023
+free_op:
1024
+ if (op->frames != &op->sframe)
1025
+ kfree(op->frames);
1026
+ kfree(op);
1027
+ return err;
10241028 }
10251029
10261030 /*
....@@ -1517,6 +1521,12 @@
15171521
15181522 lock_sock(sk);
15191523
1524
+#if IS_ENABLED(CONFIG_PROC_FS)
1525
+ /* remove procfs entry */
1526
+ if (net->can.bcmproc_dir && bo->bcm_proc_read)
1527
+ remove_proc_entry(bo->procname, net->can.bcmproc_dir);
1528
+#endif /* CONFIG_PROC_FS */
1529
+
15201530 list_for_each_entry_safe(op, next, &bo->tx_ops, list)
15211531 bcm_remove_op(op);
15221532
....@@ -1551,12 +1561,6 @@
15511561
15521562 list_for_each_entry_safe(op, next, &bo->rx_ops, list)
15531563 bcm_remove_op(op);
1554
-
1555
-#if IS_ENABLED(CONFIG_PROC_FS)
1556
- /* remove procfs entry */
1557
- if (net->can.bcmproc_dir && bo->bcm_proc_read)
1558
- remove_proc_entry(bo->procname, net->can.bcmproc_dir);
1559
-#endif /* CONFIG_PROC_FS */
15601564
15611565 /* remove device reference */
15621566 if (bo->bound) {