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

drivers/wifi/esp_at: Fix system crash caused by null pointer #81806

Closed
wants to merge 2 commits into from

Conversation

hongquan-prog
Copy link
Contributor

The code for checking the null pointer is incorrect,
with ESP_AT_CIPDINFO_USE turned on, after a soft
reboot of the host and before a reboot of ESP32, the
host may receive an incorrect IPD message causing
a system crash.

Fixes #81804

@zephyrbot zephyrbot added area: Wi-Fi Wi-Fi size: XS A PR changing only a single line of code labels Nov 23, 2024
mniestroj
mniestroj previously approved these changes Nov 23, 2024
sylvioalves
sylvioalves previously approved these changes Nov 24, 2024
MaochenWang1
MaochenWang1 previously approved these changes Nov 24, 2024
jukkar
jukkar previously approved these changes Nov 26, 2024
@sylvioalves
Copy link
Collaborator

@hongquan-prog would you mind rebasing this PR?

@hongquan-prog
Copy link
Contributor Author

@hongquan-prog would you mind rebasing this PR?

OK

kartben
kartben previously approved these changes Nov 29, 2024
@sylvioalves
Copy link
Collaborator

sylvioalves commented Nov 29, 2024

@hongquan-prog Ci is failing for other reason, but one is related to esp.c stuff.
Would you add extra change in this PR to fix build warning?

L870:

	int data_offset;
	long data_len;

Please, initialize the variables as in below.

	int data_offset = 0;
	long data_len = 0;

@hongquan-prog
Copy link
Contributor Author

@hongquan-prog Ci is failing for other reason, but one is related to esp.c stuff. Would you add extra change in this PR to fix build warning?

L870:

	int data_offset;
	long data_len;

Please, initialize the variables as in below.

	int data_offset = 0;
	long data_len = 0;

👌

MaochenWang1
MaochenWang1 previously approved these changes Dec 2, 2024
sylvioalves
sylvioalves previously approved these changes Dec 2, 2024
mniestroj
mniestroj previously approved these changes Dec 2, 2024
@hongquan-prog
Copy link
Contributor Author

@sylvioalves I've rebased it, so if there's a new update at the time of the merge, it may need to be rebased by the person who merged it.

struct esp_socket *sock = NULL;
int data_offset = 0;
long data_len = 0;
int err = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to initialize the err variable as value to it is set few lines below.

Copy link
Contributor Author

@hongquan-prog hongquan-prog Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌,sorry, I'm used to giving initial values to all variables, so do I need to change this place?

int data_offset = 0;
long data_len = 0;
int err = 0;
int ret = 0;
Copy link
Member

@jukkar jukkar Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also initializing ret is not needed (because you set a value to it later in the function).

The code for checking the null pointer is incorrect,
with ESP_AT_CIPDINFO_USE turned on, after a soft reboot
of the host and before a reboot of ESP32, the host may
receive an incorrect IPD message causing a system crash.

Fixes zephyrproject-rtos#81804

Signed-off-by: Hongquan Li <hongquan.prog@gmail.com>
Setting initial values for uninitialised variables.

Signed-off-by: Hongquan Li <hongquan.prog@gmail.com>
@kartben kartben requested a review from jukkar December 20, 2024 21:33
@hongquan-prog hongquan-prog deleted the espat branch December 31, 2024 06:40
@kartben
Copy link
Collaborator

kartben commented Dec 31, 2024

@hongquan-prog did you intend to close this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Wi-Fi Wi-Fi size: XS A PR changing only a single line of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

drivers/wifi/espat: Invalid parameter checks lead to system crashes
7 participants