int currframe;
struct can_frame *frames;
struct can_frame *last_frames;
+ struct can_frame sframe;
+ struct can_frame last_sframe;
struct sock *sk;
};
}
/* do a real check in can_frame data section */
+
if ((GET_U64(&op->frames[index]) & GET_U64(rxdata)) !=
(GET_U64(&op->frames[index]) & GET_U64(&op->last_frames[index]))) {
bcm_rx_update_and_send(op, &op->last_frames[index], rxdata);
if (op->flags & RX_CHECK_DLC) {
/* do a real check in can_frame dlc */
-
if (rxdata->can_dlc != (op->last_frames[index].can_dlc &
BCM_CAN_DLC_MASK)) {
bcm_rx_update_and_send(op, &op->last_frames[index],
op->can_id = msg_head->can_id;
/* create array for can_frames and copy the data */
- op->frames = kmalloc(msg_head->nframes * CFSIZ, GFP_KERNEL);
- if(!op->frames) {
- kfree(op);
- return -ENOMEM;
- }
+ if (msg_head->nframes > 1) {
+ op->frames = kmalloc(msg_head->nframes * CFSIZ,
+ GFP_KERNEL);
+ if (!op->frames) {
+ kfree(op);
+ return -ENOMEM;
+ }
+ } else
+ op->frames = &op->sframe;
for (i = 0; i < msg_head->nframes; i++) {
- err = memcpy_fromiovec((u8*)&op->frames[i],
+ err = memcpy_fromiovec((u8 *)&op->frames[i],
msg->msg_iov, CFSIZ);
if (err < 0) {
- kfree(op->frames);
+ if (op->frames != &op->sframe)
+ kfree(op->frames);
kfree(op);
return err;
}
if (msg_head->nframes) {
/* update can_frames content */
- err = memcpy_fromiovec((u8*)op->frames,
+ err = memcpy_fromiovec((u8 *)op->frames,
msg->msg_iov,
msg_head->nframes * CFSIZ);
if (err < 0)
op->can_id = msg_head->can_id;
op->nframes = msg_head->nframes;
- if (msg_head->nframes) {
-
+ if (msg_head->nframes > 1) {
/* create array for can_frames and copy the data */
op->frames = kmalloc(msg_head->nframes * CFSIZ,
GFP_KERNEL);
return -ENOMEM;
}
- err = memcpy_fromiovec((u8*)op->frames, msg->msg_iov,
- msg_head->nframes * CFSIZ);
- if (err < 0) {
- kfree(op->frames);
- kfree(op);
- return err;
- }
-
- /* create array for received can_frames */
+ /* create and init array for received can_frames */
op->last_frames = kzalloc(msg_head->nframes * CFSIZ,
GFP_KERNEL);
if (!op->last_frames) {
}
} else {
- /* op->frames = NULL due to memset */
-
- /* even when we have the RX_FILTER_ID case, we need */
- /* to store the last frame for the throttle feature */
+ op->frames = &op->sframe;
+ op->last_frames = &op->last_sframe;
+ }
- /* create array for received can_frames */
- op->last_frames = kzalloc(CFSIZ, GFP_KERNEL);
- if (!op->last_frames) {
+ if (msg_head->nframes) {
+ err = memcpy_fromiovec((u8 *)op->frames, msg->msg_iov,
+ msg_head->nframes * CFSIZ);
+ if (err < 0) {
+ if (op->frames != &op->sframe)
+ kfree(op->frames);
+ if (op->last_frames != &op->last_sframe)
+ kfree(op->last_frames);
kfree(op);
- return -ENOMEM;
+ return err;
}
}