From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08E3FC433E8 for ; Tue, 14 Jul 2020 21:23:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E3B8C2071B for ; Tue, 14 Jul 2020 21:23:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728098AbgGNVXW (ORCPT ); Tue, 14 Jul 2020 17:23:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:60694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728260AbgGNVXW (ORCPT ); Tue, 14 Jul 2020 17:23:22 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F038D2074B; Tue, 14 Jul 2020 21:23:21 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.93) (envelope-from ) id 1jvSOX-004vbC-1e; Tue, 14 Jul 2020 17:23:21 -0400 Message-ID: <20200714212320.928819723@goodmis.org> User-Agent: quilt/0.66 Date: Tue, 14 Jul 2020 17:19:37 -0400 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: Namhyung Kim , "Tzvetomir Stoyanov (VMware)" Subject: [PATCH 8/8] libtraceevent: Handle possible strdup() error in tep_add_plugin_path() API References: <20200714211929.828530560@goodmis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Tzvetomir Stoyanov (VMware)" Free allocated resources and return -1 in case strdup() fails in tep_add_plugin_path() API. Link: https://lore.kernel.org/r/CAM9d7chfvJwodpVrHGc5E2J80peRojmYV_fD8x3cpn9HFRUw2g@mail.gmail.com Link: https://lore.kernel.org/linux-trace-devel/20200714103027.2477584-9-tz.stoyanov@gmail.com Suggested-by: Namhyung Kim Acked-by: Namhyung Kim Signed-off-by: Tzvetomir Stoyanov (VMware) Signed-off-by: Steven Rostedt (VMware) --- lib/traceevent/event-plugin.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/traceevent/event-plugin.c b/lib/traceevent/event-plugin.c index 841e41c68ad0..4a3f7d3f7969 100644 --- a/lib/traceevent/event-plugin.c +++ b/lib/traceevent/event-plugin.c @@ -666,6 +666,10 @@ int tep_add_plugin_path(struct tep_handle *tep, char *path, return -1; dir->path = strdup(path); + if (!dir->path) { + free(dir); + return -1; + } dir->prio = prio; dir->next = tep->plugins_dir; tep->plugins_dir = dir; -- 2.26.2