Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Division by zero segfault for custom serial baud rates #22

Open
arneboe opened this issue Oct 30, 2017 · 1 comment
Open

Division by zero segfault for custom serial baud rates #22

arneboe opened this issue Oct 30, 2017 · 1 comment

Comments

@arneboe
Copy link

arneboe commented Oct 30, 2017

ss.custom_divisor = (ss.baud_base + (brate / 2)) / brate;
int closestSpeed = ss.baud_base / ss.custom_divisor;

ss.custom_divisor becomes zero if ss.baud_base <= brate / 2.
In this case the driver segfaults due to the division by zero. At least on my machine ss.baud_base seems to be zero by default thus this code segfaults for all custom baud rates.

@doudou
Copy link
Member

doudou commented Oct 30, 2017

A quick googling seems to indicate that one should set a standard baudrate before doing this.

https://github.com/cbrake/linux-serial-test/blob/master/linux-serial-test.c#L490

Could you try if this helps ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants