You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/12/13 11:34:59 UTC
[incubator-nuttx] branch master updated: charger: fix crash when notify without pollwaiter
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 8b0d45a charger: fix crash when notify without pollwaiter
8b0d45a is described below
commit 8b0d45abefb8483be53d0285c2c1e18b4b7942bc
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Mon Dec 13 16:38:36 2021 +0800
charger: fix crash when notify without pollwaiter
Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
drivers/power/battery_charger.c | 7 ++++++-
drivers/power/battery_gauge.c | 7 ++++++-
drivers/power/battery_monitor.c | 7 ++++++-
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/power/battery_charger.c b/drivers/power/battery_charger.c
index ea62a10..6c022b74 100644
--- a/drivers/power/battery_charger.c
+++ b/drivers/power/battery_charger.c
@@ -99,12 +99,17 @@ static const struct file_operations g_batteryops =
****************************************************************************/
static int battery_charger_notify(FAR struct battery_charger_priv_s *priv,
- uint32_t mask)
+ uint32_t mask)
{
FAR struct pollfd *fd = priv->fds;
int semcnt;
int ret;
+ if (!fd)
+ {
+ return OK;
+ }
+
ret = nxsem_wait_uninterruptible(&priv->lock);
if (ret < 0)
{
diff --git a/drivers/power/battery_gauge.c b/drivers/power/battery_gauge.c
index 69377ae..eed9b3b 100644
--- a/drivers/power/battery_gauge.c
+++ b/drivers/power/battery_gauge.c
@@ -101,12 +101,17 @@ static const struct file_operations g_batteryops =
****************************************************************************/
static int battery_gauge_notify(FAR struct battery_gauge_priv_s *priv,
- uint32_t mask)
+ uint32_t mask)
{
FAR struct pollfd *fd = priv->fds;
int semcnt;
int ret;
+ if (!fd)
+ {
+ return OK;
+ }
+
ret = nxsem_wait_uninterruptible(&priv->lock);
if (ret < 0)
{
diff --git a/drivers/power/battery_monitor.c b/drivers/power/battery_monitor.c
index 31eec41..2a6ddec 100644
--- a/drivers/power/battery_monitor.c
+++ b/drivers/power/battery_monitor.c
@@ -100,12 +100,17 @@ static const struct file_operations g_batteryops =
****************************************************************************/
static int battery_monitor_notify(FAR struct battery_monitor_priv_s *priv,
- uint32_t mask)
+ uint32_t mask)
{
FAR struct pollfd *fd = priv->fds;
int semcnt;
int ret;
+ if (!fd)
+ {
+ return OK;
+ }
+
ret = nxsem_wait_uninterruptible(&priv->lock);
if (ret < 0)
{