Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1762500pxj; Wed, 19 May 2021 13:20:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9vpdotsLYwm/56U1mpa5XEVVXEGM1jCZisMAhv9MmMIzTkUxgcDxOCBfGd68xkg6RX3t/ X-Received: by 2002:a05:6402:35d4:: with SMTP id z20mr888421edc.164.1621455620239; Wed, 19 May 2021 13:20:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621455620; cv=none; d=google.com; s=arc-20160816; b=e6O5TZuQnLkYQPOXlC+H7VNVjHmGJ/ZonlwF9LAPzXpPmO5tQM8aAt3YnbLSG8tS4R wQWPcamLSzx6p6wmI3bKK9a2B58vFAUUdDxZfF7S9tKuF4gd21UFrynBSeWwPfdakAwm lS/jP5FlRDGY5x6hz9H9wFPXvu80qLBMgCOAxjTIoaoU2lmHlyypjukBgf2VyuShYyZx 11QBzWakfB9B8ckGYyqpec4mzRD5fkc2D9+9cmrXb0TwY84xZGczjCT2JCuMik8duJqG LYyKsye5tWG93W03yMjB/na6IZBxrsSQoHcwUSr0ZQjmwq/wlpqEh3WvhjQhkzBvixjB XUIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=F5DosGjcWl2sSk8kTRSGDWlnAMyHCEEYRXKHA7IOuwA=; b=JL3UvWMJEkZL1W17jdYRX50F211Rs1BhR22aSdSpuepXpDz/DGH65GWvchYKYDziEN s7T2PmzR2bZUKJhvunnNwmgj0EYWQcflUElyg1uu/K0b0thj/8Fx+v5H72FOnwct3HE1 FwgvPYYqJa+TrXm3huRIVQtkHRI3hXQlj+BdLrNUhyK5eGuc7iIAkIaf10/Tkzt7sNBG 7GzIcZUFiTtVQ3rVjxXEJisWzzty+hcZpLnvQaWxofGjwFhsKSsW4stR0E/afNVFZsB8 Bx+56YjgswW3mZXUMRoKckQyD6vIBg3kV9QwJ/ec5Fiqo5jSsgweBaXY5VyP+zPmGJmK u3EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UTn97xd6; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g14si537896ejc.707.2021.05.19.13.19.56; Wed, 19 May 2021 13:20:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UTn97xd6; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230504AbhESSLU (ORCPT + 99 others); Wed, 19 May 2021 14:11:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230023AbhESSLU (ORCPT ); Wed, 19 May 2021 14:11:20 -0400 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28980C06175F for ; Wed, 19 May 2021 11:09:59 -0700 (PDT) Received: by mail-yb1-xb36.google.com with SMTP id w1so7972259ybt.1 for ; Wed, 19 May 2021 11:09:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F5DosGjcWl2sSk8kTRSGDWlnAMyHCEEYRXKHA7IOuwA=; b=UTn97xd6DQitKGq1EZPUrlJ6qBRq7BwZinoqHRrlF8BM2B7Di0dddtSkKm4gwZ7x3/ /aXsD5bnU2Vdwz05XK49YFmW90hAx1sxd1J3PlZ4cxIZm/RR4S7fvvIbiA9M3I3tUx+Z EubiceUWAoNDdK4P+CvuqBQIoxb25ysNXnukhYB8Boito3dyxR164VQGwGzY/jSFv9xS EM0cDWrhjHamu2w/PL6EUX7mdu3pf0OtVIQ6plqUP1Dbw7gE5SLUIe6g3FWy4/mjqwWZ 3rOCx7mUxSXDloWRjD+7tFAj0cx1EGdXHItzX/tslEiBduB51eErFt40onR+dpF7NcEF xpGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F5DosGjcWl2sSk8kTRSGDWlnAMyHCEEYRXKHA7IOuwA=; b=NccoB2nbee0FTjwCppsfh5tZHKUD8s2D8l/GaZ2/QZe5GXKxBksvINCNMV+/ibUAni qoC0vBfpsm8FR1fA3P35Z/zixVRChhHdMLTBiVMuf7PxhPtkK8Ahe0H8TYDBO8T7R1Gh N1gZ5EaDyypoao7OlcUtwcD7CS68BGUEzWyd+accjcGYBur8nMgb+7h9f648msBRFeOU CauWe6OePco4FKh0lN7hbM5bcxIhqYZ7TrUUyuUqlE58pepMIWY6DPCAupUmB6li9mQD R1v+xBTMpyu/0GbTrYtQMMuSMrhoIHB+LqbZsDKZYmSIp25YNC32SXQosk4VqkLa/sYH HEwA== X-Gm-Message-State: AOAM533oDE46EyYyT5cH2AQxIoKI1gi2SDAPmI3ZWzEZu9/ANTAhUDXv m8TZBEfjDtoI2qJBctVVUyx8+Yzsd4hfFiMlnRw= X-Received: by 2002:a25:a466:: with SMTP id f93mr1139218ybi.264.1621447798325; Wed, 19 May 2021 11:09:58 -0700 (PDT) MIME-Version: 1.0 References: <20210515094307.16fb1572@ivy-bridge> In-Reply-To: <20210515094307.16fb1572@ivy-bridge> From: Luiz Augusto von Dentz Date: Wed, 19 May 2021 11:09:47 -0700 Message-ID: Subject: Re: [Bluez PATCH ] Fix memory leaks in obex To: Steve Grubb Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Steve, On Sat, May 15, 2021 at 7:16 PM Steve Grubb wrote: > > This patch fixes a couple memory leaks. > > In filesystem, g_file_get_contents allocates fresh memory to buf. > It needs to be freed after conversion to a GString object. > > Destination was missed on an error path as is mld. > > --- > obexd/plugins/filesystem.c | 2 +- > obexd/plugins/ftp.c | 8 ++++++-- > obexd/plugins/messages-dummy.c | 1 + > 3 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/obexd/plugins/filesystem.c b/obexd/plugins/filesystem.c > index 09bff8ad0..44e3cf3d2 100644 > --- a/obexd/plugins/filesystem.c > +++ b/obexd/plugins/filesystem.c@@ -416,6 +416,7 @@ static void *capability_open(const char *name, int oflag, mode_t mode, > } > > object->buffer = g_string_new(buf); > + g_free(buf); > > if (size) > *size = object->buffer->len; > diff --git a/obexd/plugins/ftp.c b/obexd/plugins/ftp.c > index 259bfcae2..4b04bab06 100644 > --- a/obexd/plugins/ftp.c > +++ b/obexd/plugins/ftp.c > @@ -386,8 +386,10 @@ static int ftp_copy(struct ftp_session *ftp, const char *name, > ret = verify_path(destdir); > g_free(destdir); > > - if (ret < 0) > + if (ret < 0) { > + g_free(destination); > return ret; > + } > > source = g_build_filename(ftp->folder, name, NULL); > > @@ -424,8 +426,10 @@ static int ftp_move(struct ftp_session *ftp, const char *name, > ret = verify_path(destdir); > g_free(destdir); > > - if (ret < 0) > + if (ret < 0) { > + g_free(destination); > return ret; > + } > > source = g_build_filename(ftp->folder, name, NULL); > > diff --git a/obexd/plugins/messages-dummy.c b/obexd/plugins/messages-dummy.c > index 34199fa05..e37b52df6 100644 > --- a/obexd/plugins/messages-dummy.c > +++ b/obexd/plugins/messages-dummy.c > @@ -488,6 +488,7 @@ int messages_get_messages_listing(void *session, const char *name, > int err = -errno; > DBG("fopen(): %d, %s", -err, strerror(-err)); > g_free(path); > + g_free(mld); > return -EBADR; > } > } > -- > 2.31.1 Applied, thanks. -- Luiz Augusto von Dentz