fix user get ifindex error issue
PATCH v2 1/1 fix user get ifindex error issue
when user program get the ifindex cross the ioctl SIOCGIFINDEX, the ifindex is a random data. this patch fix the user program getting ifindex error issue.
--- kernel/drivers/can/m_can/rtcan_m_can.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/drivers/can/m_can/rtcan_m_can.c +4 -1
@@ -474,6 +474,8 @@ static int m_can_read_fifo(struct rtcan_device *dev, u32 rxfs)u32 timestamp =0 ;int err; + cf->can_ifindex = dev->ifindex; +/* calculate the fifo get index for where to read data */ fgi =FIELD_GET (RXFS_FGI_MASK , rxfs); err =m_can_fifo_read (cdev, fgi,M_CAN_FIFO_ID , &fifo_header,2 );
@@ -550,7 +552,8 @@ static int m_can_handle_lost_msg(struct rtcan_device *dev)rtcandev_err (dev,"msg lost in rxf0\n" ); skb.rb_frame_size =EMPTY_RB_FRAME_SIZE +CAN_ERR_DLC ; - + + frame->can_ifindex = dev->ifindex; frame->can_id |=CAN_ERR_CRTL ; frame->data[1 ] =CAN_ERR_CRTL_RX_OVERFLOW ; frame->can_dlc =CAN_ERR_DLC ;
Signature · 1 line
2.34.1
Quoted 22 lines · liuyang
when user program get the ifindex cross the ioctl SIOCGIFINDEX, the ifindex is a random data. this patch fix the user program getting ifindex error issue.
Signed-off-by liuyang <[email protected]>--- kernel/drivers/can/m_can/rtcan_m_can.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)kernel/drivers/can/m_can/rtcan_m_can.c +2
-0@@ -474,6 +474,8 @@ static int m_can_read_fifo(struct rtcan_device *dev, u32 rxfs)u32 timestamp =0 ;int err; + cf->can_ifindex = dev->ifindex; +/* calculate the fifo get index for where to read data */ fgi =FIELD_GET (RXFS_FGI_MASK , rxfs); err =m_can_fifo_read (cdev, fgi,M_CAN_FIFO_ID , &fifo_header,2 );
kernel/drivers/can/m_can/rtcan_m_can.c static int m_can_handle_lost_msg(struct rtcan_device *dev) · line 555
Quoted 5 lines
kernel/drivers/can/m_can/rtcan_m_can.c +1
-1@@ -550,7 +552,8 @@ static int m_can_handle_lost_msg(struct rtcan_device *dev)rtcandev_err (dev,"msg lost in rxf0\n" ); skb.rb_frame_size =EMPTY_RB_FRAME_SIZE +CAN_ERR_DLC ; - +
Minor detail for the future: Please avoid style changes away from kernel coding style.
kernel/drivers/can/m_can/rtcan_m_can.c static int m_can_handle_lost_msg(struct rtcan_device *dev) · line 559
Quoted 4 lines
kernel/drivers/can/m_can/rtcan_m_can.c +1
-0+ frame->can_ifindex = dev->ifindex; frame->can_id |=CAN_ERR_CRTL ; frame->data[1 ] =CAN_ERR_CRTL_RX_OVERFLOW ; frame->can_dlc =CAN_ERR_DLC ;
The patch would otherwise be fine - if the code that your are patching here was already accepted upstream.
I assume this applies on top of [1]. So, as there are open issues with
[1] anyway (see my feedback), you should address this issues here along with the other remarks in a version 3 of that patch.
Thanks,
Jan
[1]
https://lore.kernel.org/xenomai/[email protected]/T/#t
Signature · 2 lines
Siemens AG, Technology Linux Expert Center