lkml.org 
[lkml]   [2022]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.19 0791/1157] rtla/utils: Use calloc and check the potential memory allocation failure
    Date
    From: jianchunfu <jianchunfu@cmss.chinamobile.com>

    [ Upstream commit b5f37a0b6f667f5c72340ca9dcd7703f261cb981 ]

    Replace malloc with calloc and add memory allocating check
    of mon_cpus before used.

    Link: https://lkml.kernel.org/r/20220615073348.6891-1-jianchunfu@cmss.chinamobile.com

    Fixes: 7d0dc9576dc3 ("rtla/timerlat: Add --dma-latency option")
    Signed-off-by: jianchunfu <jianchunfu@cmss.chinamobile.com>
    Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    tools/tracing/rtla/src/utils.c | 5 +++--
    1 file changed, 3 insertions(+), 2 deletions(-)

    diff --git a/tools/tracing/rtla/src/utils.c b/tools/tracing/rtla/src/utils.c
    index 5352167a1e75..5ae2fa96fde1 100644
    --- a/tools/tracing/rtla/src/utils.c
    +++ b/tools/tracing/rtla/src/utils.c
    @@ -106,8 +106,9 @@ int parse_cpu_list(char *cpu_list, char **monitored_cpus)

    nr_cpus = sysconf(_SC_NPROCESSORS_CONF);

    - mon_cpus = malloc(nr_cpus * sizeof(char));
    - memset(mon_cpus, 0, (nr_cpus * sizeof(char)));
    + mon_cpus = calloc(nr_cpus, sizeof(char));
    + if (!mon_cpus)
    + goto err;

    for (p = cpu_list; *p; ) {
    cpu = atoi(p);
    --
    2.35.1


    \
     
     \ /
      Last update: 2022-08-16 06:47    [W:4.303 / U:1.072 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site