Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf script: Add missing calls to Py_DECREF for return values

Signed-off-by: Joseph Schuchart <joseph.schuchart@tu-dresden.de>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
Link: http://lkml.kernel.org/r/53BD4EBF.5050407@tu-dresden.de
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Joseph Schuchart and committed by
Arnaldo Carvalho de Melo
05f832e3 3be8e2a0

+10 -2
+10 -2
tools/perf/util/scripting-engines/trace-event-python.c
··· 50 50 51 51 static PyObject *main_module, *main_dict; 52 52 53 + static void handler_call_die(const char *handler_name) NORETURN; 53 54 static void handler_call_die(const char *handler_name) 54 55 { 55 56 PyErr_Print(); 56 57 Py_FatalError("problem in Python trace event handler"); 58 + // Py_FatalError does not return 59 + // but we have to make the compiler happy 60 + abort(); 57 61 } 58 62 59 63 /* ··· 101 97 retval = PyObject_CallObject(handler, t); 102 98 if (retval == NULL) 103 99 handler_call_die(handler_name); 100 + Py_DECREF(retval); 104 101 } 105 102 106 103 Py_DECREF(t); ··· 148 143 retval = PyObject_CallObject(handler, t); 149 144 if (retval == NULL) 150 145 handler_call_die(handler_name); 146 + Py_DECREF(retval); 151 147 } 152 148 153 149 Py_DECREF(t); ··· 367 361 retval = PyObject_CallObject(handler, t); 368 362 if (retval == NULL) 369 363 handler_call_die(handler_name); 364 + Py_DECREF(retval); 370 365 } else { 371 366 handler = PyDict_GetItemString(main_dict, "trace_unhandled"); 372 367 if (handler && PyCallable_Check(handler)) { ··· 375 368 retval = PyObject_CallObject(handler, t); 376 369 if (retval == NULL) 377 370 handler_call_die("trace_unhandled"); 371 + Py_DECREF(retval); 378 372 } 379 373 Py_DECREF(dict); 380 374 } ··· 435 427 retval = PyObject_CallObject(handler, t); 436 428 if (retval == NULL) 437 429 handler_call_die(handler_name); 430 + Py_DECREF(retval); 438 431 exit: 439 432 Py_DECREF(dict); 440 433 Py_DECREF(t); ··· 557 548 retval = PyObject_CallObject(handler, NULL); 558 549 if (retval == NULL) 559 550 handler_call_die("trace_end"); 560 - else 561 - Py_DECREF(retval); 551 + Py_DECREF(retval); 562 552 out: 563 553 Py_XDECREF(main_dict); 564 554 Py_XDECREF(main_module);