.. | .. |
---|
936 | 936 | |
---|
937 | 937 | cf = op->frames + op->cfsiz * i; |
---|
938 | 938 | err = memcpy_from_msg((u8 *)cf, msg, op->cfsiz); |
---|
| 939 | + if (err < 0) |
---|
| 940 | + goto free_op; |
---|
939 | 941 | |
---|
940 | 942 | if (op->flags & CAN_FD_FRAME) { |
---|
941 | 943 | if (cf->len > 64) |
---|
.. | .. |
---|
945 | 947 | err = -EINVAL; |
---|
946 | 948 | } |
---|
947 | 949 | |
---|
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; |
---|
954 | 952 | |
---|
955 | 953 | if (msg_head->flags & TX_CP_CAN_ID) { |
---|
956 | 954 | /* copy can_id into frame */ |
---|
.. | .. |
---|
1021 | 1019 | bcm_tx_start_timer(op); |
---|
1022 | 1020 | |
---|
1023 | 1021 | 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; |
---|
1024 | 1028 | } |
---|
1025 | 1029 | |
---|
1026 | 1030 | /* |
---|
.. | .. |
---|
1517 | 1521 | |
---|
1518 | 1522 | lock_sock(sk); |
---|
1519 | 1523 | |
---|
| 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 | + |
---|
1520 | 1530 | list_for_each_entry_safe(op, next, &bo->tx_ops, list) |
---|
1521 | 1531 | bcm_remove_op(op); |
---|
1522 | 1532 | |
---|
.. | .. |
---|
1551 | 1561 | |
---|
1552 | 1562 | list_for_each_entry_safe(op, next, &bo->rx_ops, list) |
---|
1553 | 1563 | 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 */ |
---|
1560 | 1564 | |
---|
1561 | 1565 | /* remove device reference */ |
---|
1562 | 1566 | if (bo->bound) { |
---|