|
|
aa8144 |
commit 3dca35f17effa102b7140d5554401ef2292425b7
|
|
|
aa8144 |
Author: Aristeu Rozanski <aris@redhat.com>
|
|
|
aa8144 |
Date: Tue Jan 7 14:49:19 2020 -0500
|
|
|
aa8144 |
|
|
|
aa8144 |
rasdaemon: fix error handling in ras_mc_event_opendb()
|
|
|
aa8144 |
|
|
|
aa8144 |
Found with covscan that the return value from ras_mc_prepare_stmt() and from
|
|
|
aa8144 |
ras_mc_event_opendb() itself aren't checked.
|
|
|
aa8144 |
|
|
|
aa8144 |
Signed-off-by: Aristeu Rozanski <aris@redhat.com>
|
|
|
aa8144 |
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
|
|
|
aa8144 |
|
|
|
aa8144 |
---
|
|
|
aa8144 |
ras-events.c | 17 +++++++++++++----
|
|
|
aa8144 |
ras-record.c | 42 +++++++++++++++++++++++++++++++-----------
|
|
|
aa8144 |
2 files changed, 44 insertions(+), 15 deletions(-)
|
|
|
aa8144 |
|
|
|
aa8144 |
--- rasdaemon-0.4.1.orig/ras-events.c 2020-03-18 15:58:10.477721778 -0400
|
|
|
aa8144 |
+++ rasdaemon-0.4.1/ras-events.c 2020-03-18 15:59:05.398236266 -0400
|
|
|
aa8144 |
@@ -348,8 +348,10 @@ if (fds[i].fd < 0) {
|
|
|
aa8144 |
}
|
|
|
aa8144 |
|
|
|
aa8144 |
log(TERM, LOG_INFO, "Listening to events for cpus 0 to %d\n", n_cpus - 1);
|
|
|
aa8144 |
- if (pdata[0].ras->record_events)
|
|
|
aa8144 |
- ras_mc_event_opendb(pdata[0].cpu, pdata[0].ras);
|
|
|
aa8144 |
+ if (pdata[0].ras->record_events) {
|
|
|
aa8144 |
+ if (ras_mc_event_opendb(pdata[0].cpu, pdata[0].ras))
|
|
|
aa8144 |
+ goto error;
|
|
|
aa8144 |
+ }
|
|
|
aa8144 |
|
|
|
aa8144 |
do {
|
|
|
aa8144 |
ready = poll(fds, n_cpus, -1);
|
|
|
aa8144 |
@@ -485,8 +487,15 @@ if (fd < 0) {
|
|
|
aa8144 |
}
|
|
|
aa8144 |
|
|
|
aa8144 |
log(TERM, LOG_INFO, "Listening to events on cpu %d\n", pdata->cpu);
|
|
|
aa8144 |
- if (pdata->ras->record_events)
|
|
|
aa8144 |
- ras_mc_event_opendb(pdata->cpu, pdata->ras);
|
|
|
aa8144 |
+ if (pdata->ras->record_events) {
|
|
|
aa8144 |
+ if (ras_mc_event_opendb(pdata->cpu, pdata->ras)) {
|
|
|
aa8144 |
+ log(TERM, LOG_ERR, "Can't open database\n");
|
|
|
aa8144 |
+ close(fd);
|
|
|
aa8144 |
+ kbuffer_free(kbuf);
|
|
|
aa8144 |
+ free(page);
|
|
|
aa8144 |
+ return 0;
|
|
|
aa8144 |
+ }
|
|
|
aa8144 |
+ }
|
|
|
aa8144 |
|
|
|
aa8144 |
read_ras_event(fd, pdata, kbuf, page);
|
|
|
aa8144 |
|
|
|
aa8144 |
--- rasdaemon-0.4.1.orig/ras-record.c 2020-03-18 15:58:10.478721769 -0400
|
|
|
aa8144 |
+++ rasdaemon-0.4.1/ras-record.c 2020-03-18 16:02:31.382415310 -0400
|
|
|
aa8144 |
@@ -506,8 +506,7 @@ int ras_mc_event_opendb(unsigned cpu, st
|
|
|
aa8144 |
log(TERM, LOG_ERR,
|
|
|
aa8144 |
"cpu %u: Failed to initialize sqlite: error = %d\n",
|
|
|
aa8144 |
cpu, rc);
|
|
|
aa8144 |
- free(priv);
|
|
|
aa8144 |
- return -1;
|
|
|
aa8144 |
+ goto error;
|
|
|
aa8144 |
}
|
|
|
aa8144 |
|
|
|
aa8144 |
do {
|
|
|
aa8144 |
@@ -523,51 +522,72 @@ usleep(10000);
|
|
|
aa8144 |
log(TERM, LOG_ERR,
|
|
|
aa8144 |
"cpu %u: Failed to connect to %s: error = %d\n",
|
|
|
aa8144 |
cpu, SQLITE_RAS_DB, rc);
|
|
|
aa8144 |
- free(priv);
|
|
|
aa8144 |
- return -1;
|
|
|
aa8144 |
+ goto error;
|
|
|
aa8144 |
}
|
|
|
aa8144 |
priv->db = db;
|
|
|
aa8144 |
|
|
|
aa8144 |
rc = ras_mc_create_table(priv, &mc_event_tab);
|
|
|
aa8144 |
- if (rc == SQLITE_OK)
|
|
|
aa8144 |
+ if (rc == SQLITE_OK) {
|
|
|
aa8144 |
rc = ras_mc_prepare_stmt(priv, &priv->stmt_mc_event,
|
|
|
aa8144 |
&mc_event_tab);
|
|
|
aa8144 |
+ if (rc != SQLITE_OK)
|
|
|
aa8144 |
+ goto error;
|
|
|
aa8144 |
+ }
|
|
|
aa8144 |
|
|
|
aa8144 |
#ifdef HAVE_AER
|
|
|
aa8144 |
rc = ras_mc_create_table(priv, &aer_event_tab);
|
|
|
aa8144 |
- if (rc == SQLITE_OK)
|
|
|
aa8144 |
+ if (rc == SQLITE_OK) {
|
|
|
aa8144 |
rc = ras_mc_prepare_stmt(priv, &priv->stmt_aer_event,
|
|
|
aa8144 |
&aer_event_tab);
|
|
|
aa8144 |
+ if (rc != SQLITE_OK)
|
|
|
aa8144 |
+ goto error;
|
|
|
aa8144 |
+ }
|
|
|
aa8144 |
#endif
|
|
|
aa8144 |
|
|
|
aa8144 |
#ifdef HAVE_EXTLOG
|
|
|
aa8144 |
rc = ras_mc_create_table(priv, &extlog_event_tab);
|
|
|
aa8144 |
- if (rc == SQLITE_OK)
|
|
|
aa8144 |
+ if (rc == SQLITE_OK) {
|
|
|
aa8144 |
rc = ras_mc_prepare_stmt(priv, &priv->stmt_extlog_record,
|
|
|
aa8144 |
&extlog_event_tab);
|
|
|
aa8144 |
+ if (rc != SQLITE_OK)
|
|
|
aa8144 |
+ goto error;
|
|
|
aa8144 |
+ }
|
|
|
aa8144 |
#endif
|
|
|
aa8144 |
|
|
|
aa8144 |
#ifdef HAVE_MCE
|
|
|
aa8144 |
rc = ras_mc_create_table(priv, &mce_record_tab);
|
|
|
aa8144 |
- if (rc == SQLITE_OK)
|
|
|
aa8144 |
+ if (rc == SQLITE_OK) {
|
|
|
aa8144 |
rc = ras_mc_prepare_stmt(priv, &priv->stmt_mce_record,
|
|
|
aa8144 |
&mce_record_tab);
|
|
|
aa8144 |
+ if (rc != SQLITE_OK)
|
|
|
aa8144 |
+ goto error;
|
|
|
aa8144 |
+ }
|
|
|
aa8144 |
#endif
|
|
|
aa8144 |
|
|
|
aa8144 |
#ifdef HAVE_NON_STANDARD
|
|
|
aa8144 |
rc = ras_mc_create_table(priv, &non_standard_event_tab);
|
|
|
aa8144 |
- if (rc == SQLITE_OK)
|
|
|
aa8144 |
+ if (rc == SQLITE_OK) {
|
|
|
aa8144 |
rc = ras_mc_prepare_stmt(priv, &priv->stmt_non_standard_record,
|
|
|
aa8144 |
&non_standard_event_tab);
|
|
|
aa8144 |
+ if (rc != SQLITE_OK)
|
|
|
aa8144 |
+ goto error;
|
|
|
aa8144 |
+ }
|
|
|
aa8144 |
#endif
|
|
|
aa8144 |
|
|
|
aa8144 |
#ifdef HAVE_ARM
|
|
|
aa8144 |
rc = ras_mc_create_table(priv, &arm_event_tab);
|
|
|
aa8144 |
- if (rc == SQLITE_OK)
|
|
|
aa8144 |
+ if (rc == SQLITE_OK) {
|
|
|
aa8144 |
rc = ras_mc_prepare_stmt(priv, &priv->stmt_arm_record,
|
|
|
aa8144 |
&arm_event_tab);
|
|
|
aa8144 |
+ if (rc != SQLITE_OK)
|
|
|
aa8144 |
+ goto error;
|
|
|
aa8144 |
+ }
|
|
|
aa8144 |
#endif
|
|
|
aa8144 |
|
|
|
aa8144 |
- ras->db_priv = priv;
|
|
|
aa8144 |
+ ras->db_priv = priv;
|
|
|
aa8144 |
return 0;
|
|
|
aa8144 |
+
|
|
|
aa8144 |
+error:
|
|
|
aa8144 |
+ free(priv);
|
|
|
aa8144 |
+ return -1;
|
|
|
aa8144 |
}
|