Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/ppp_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,13 @@ static rt_err_t ppp_device_open(struct rt_device *device, rt_uint16_t oflag)
goto __exit;
}
LOG_D("pppapi_pppos_create has created a protocol control block.");
ppp_netdev_add(&ppp_device->pppif);


/* set netif name */
ppp_device->pppif.name[0] = ppp_device->parent.parent.name[0];
ppp_device->pppif.name[1] = ppp_device->parent.parent.name[1];

ppp_netdev_add(&ppp_device->pppif);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Capture and check the return value of ppp_netdev_add.

The return value of ppp_netdev_add is not being captured or checked. If registration fails, the function continues without detecting the error.

🔧 Proposed fix
-    ppp_netdev_add(&ppp_device->pppif);
+    result = ppp_netdev_add(&ppp_device->pppif);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ppp_netdev_add(&ppp_device->pppif);
result = ppp_netdev_add(&ppp_device->pppif);
🤖 Prompt for AI Agents
In @src/ppp_device.c at line 379, ppp_netdev_add's return value must be captured
and checked so failures don't go unnoticed; modify the call where
ppp_netdev_add(&ppp_device->pppif) is invoked to store the returned int, test
for non-zero/failure, log a descriptive error (including the returned
errno/code) and perform appropriate cleanup/return (e.g., free ppp_device, undo
prior allocations, or goto an error label) instead of proceeding as if
registration succeeded.


if (result != RT_EOK)
{
LOG_E("pppapi_set_default execute failed.");
Expand Down