Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5178196ybi; Tue, 28 May 2019 08:47:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxS1mqqyVqA4r9Ax0vUw0WNF/wvNkinZOBRoiEVm5Ri41BnL6MxCcSyaH06LJhL/46EpfZz X-Received: by 2002:aa7:87ca:: with SMTP id i10mr2119164pfo.157.1559058430854; Tue, 28 May 2019 08:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559058430; cv=none; d=google.com; s=arc-20160816; b=dpbwC+cJif0ySMAloweB4TyGa6gNoSBr6oCr0n8oI3UX4/zF7M5vP0osVtyriKhY26 xdMzFaj48VJj1nEPe04cdCCHooa3YdTJ8eN5PZ3gOHL/+FctNUI5mFB24G43gsLMiXMT nrQaBBbxPaPZfwiddgVaRrrN4NSbxw4RiVCdIi437uqGVi51sKwEuGL8eyIrUBL4R6lk 7RZojNb4vQgx8T981d7uutde91m4Sa08ID2qSPTCyCgbnFy5yAFTKMBHYZPJKzPEZH/0 BL0TCMx4UA4iyV3gdF1WQG7VzHxLQaqeTaWvi8SOjbRYumVax9x0EGrYAVXIys3RxeiQ d9og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature; bh=GFLFkfjER8yL0H13A8BMLU3btt+GcTnhvj0Q8M7v0E4=; b=LIK9StasZP4A50e2KuXbE68fiK/cOAM6A6ltk8nHbuhq/BmRgHfOz9HQuzA6lcNSPk VXFVd5JeqffKjPVLQPg7UW0RIhNcvh7G+Z4k480vzUuhkwrmunfx2BFBT7DL6Y9P+R9q TDtjwF1H+aatfszwXBFGFzjMP/aO6qZYzQohZtphFSraU9ctbMU5dTBUwawXRHeT/gLU +kHaw52MXPzwsQdSQufo/JFL2rf8eoN13O0wF2qXq3E8T/jbT94vX4FyDq48tOs6ywW8 oaQCBHdB8btfr/F2YzW0T/f75a3LFJ6E6fOAFNMXYoT8eSv4ja1DMhmu5idYt4rqvWP4 H6Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="sUW0yH/D"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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. [209.132.180.67]) by mx.google.com with ESMTP id bh11si21268007plb.383.2019.05.28.08.46.55; Tue, 28 May 2019 08:47:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="sUW0yH/D"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1727781AbfE1PdE (ORCPT + 99 others); Tue, 28 May 2019 11:33:04 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:38263 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727612AbfE1PdD (ORCPT ); Tue, 28 May 2019 11:33:03 -0400 Received: by mail-lj1-f195.google.com with SMTP id 14so18160497ljj.5 for ; Tue, 28 May 2019 08:33:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=GFLFkfjER8yL0H13A8BMLU3btt+GcTnhvj0Q8M7v0E4=; b=sUW0yH/DHleYp4sJI/bVaDZt5qvr8E6UIkaysC4wZPNI6XDJxwa+CKO4WnHcm1X9OZ /8DSnruvVAETlk/ATFMFFxgQgkG0K2bkAaTFDYQqQ06O0cH77QiYapa6H7c/rDtW45ok 4lSAIbfXrX7CwarfK3aoEMDunQsHt0JilelbA/AvZbTacD5d4Tqu5GnHO5jUlp4bMsfT qAbJasWJLtPmhpwvIXEI4iCcJa107QL5m+Afe45M/ufQxQBGTKmtuA/eAnlvwe2FsugX eguwVDyN4a/KTlmjAo9gP3G3Vp+x5TBOWTxhgSPKIAJ/2q0zfbfHe/DYh3I9wf2mvxMa zDXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=GFLFkfjER8yL0H13A8BMLU3btt+GcTnhvj0Q8M7v0E4=; b=EbHwusy0xhPWSl7g5PNAME38vuwU/Pfy0x9LqOeRCd0aPDs1YXTJlOFy303JdN2gWd p/LOb/CBLqknbwUUxC3BJ579I5KI9aFvYlRzFm33waVZorUPVHI+euU8ubHbAx3i/n5B ZjNuX9zDA3qPtGRzjnxTBDviz6r/y2bqNq09BHskIueIzV1swHUgKjvGeuA2uKxsC0aS g5v2WzoQfw7q2TcAmWJSkDgxgQ0yqLvWDwo+GyyVSecR557V4QXQfsIt5yBtyXABHJa0 IrxDNzJKQKUzdtxbFCix/x+fVIdCr3w1ecomDmCuvkYJoQv1EJ/D6iUxVhfKMd6xBsj+ FXfA== X-Gm-Message-State: APjAAAUY/Ps5ZXsU9D4rDRKFZu6uLOSpTgS8hASG1N8CqhSpV2fKX3kw KTw0hgQreq0Ozb6FpPM6iS6KtGyk/5c= X-Received: by 2002:a2e:7212:: with SMTP id n18mr12309566ljc.209.1559057580562; Tue, 28 May 2019 08:33:00 -0700 (PDT) Received: from [192.168.1.15] (2-111-15-75-dynamic.dk.customer.tdc.net. [2.111.15.75]) by smtp.gmail.com with ESMTPSA id c10sm2935951lfh.79.2019.05.28.08.32.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 08:32:59 -0700 (PDT) Subject: Re: [PATCH] trace: Avoid memory leak in predicate_parse() To: Steven Rostedt Cc: mingo@redhat.com, linux-kernel@vger.kernel.org References: <20190528134659.4041-1-tomasbortoli@gmail.com> <20190528104400.388e4c3f@gandalf.local.home> <1a9137e1-bcc3-787f-267c-8b76dea41fbb@gmail.com> <20190528112956.4cf2dd9c@gandalf.local.home> From: Tomas Bortoli Openpgp: preference=signencrypt Autocrypt: addr=tomasbortoli@gmail.com; prefer-encrypt=mutual; keydata= mQINBFpCTZMBEADNZ1+Ibh0Z4pgGRcd1aOUMbe/YfHktmajjcoTnKmZZunjoUVAl8waeLITd BC2c8i1wHzHcnthrmb1izs5XlG6PZnl8n5tjysSNbwggzS1NcEK1qgn5VjNlHQ5aRMUwCC51 kicBiNmlQk2UuzzWwdheRGnaf+O1MNhC0GBeEDKQAL5obOU92pzflv6wWNACr+lHxdnpyies mOnRMjH16NjuTkrGbEmJe+MKp0qbjvR3R/dmFC1wczniRMQmV5w3MZ/N9wRappE+Atc1fOM+ wP7AWNuPvrKg4bN5uqKZLDFH7OFpxvjgVdWM40n0cQfqElWY9as+228Sltdd1XyHtUWRF2VW O1l5L0kX0+7+B5k/fpLhXqD3Z7DK7wRXpXmY59pofk7aFdcN97ZK+r6R7mqrwX4W9IpsPhkT kUyg3/Dx/khBZlJKFoUP325/hoH684bSiPEBroel9alB7gTq2ueoFwy6R3q5CMUw3D+CZWHA 3xllu46TRQ/Vt2g0cIHQNPoye2OWYFJ6kSEvaLpymjNDJ9ph2EuHegonDfOaYSq34ic2BcdB JkCgXRLP5K7KtRNJqqR+DM8xByeGmQv9yp6S97el+SiM9R53RhHawJZGz0EPl+2Q6+5mgh3u wXO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M5I0xebbxtnuTewRchVVfm7UWgLAy11pV3xM4wMSJOuqVMOz jYpWKYxDTpvsZ0ginUUY993Gb8k/CxjABEMUGVHhQPZ0OzjHIKS6cTzN6ue8bB+CGOLCaQp1 C0NRT5Tn9zpLxtf5nBExFd/zVENY5vAV2ZbKQdemO54O7j6B9DSgVRrm83GCZxbL4d+qTYBF 3tSCWw/6SG1F3q9gR9QrSC2YRjCmhijUVEh6FhZwB58TNZ1sEEttrps8TDa5tUd9 Message-ID: <7abc7172-11fd-b0e3-6381-f976c5450d4f@gmail.com> Date: Tue, 28 May 2019 17:32:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190528112956.4cf2dd9c@gandalf.local.home> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/28/19 5:29 PM, Steven Rostedt wrote: > On Tue, 28 May 2019 17:18:59 +0200 > Tomas Bortoli wrote: > >>>> + memset(prog_stack, 0, nr_preds * sizeof(*prog_stack)); >>>> + >>> >>> Can you instead just switch the allocation of prog_stack to use >>> kcalloc()? >> >> kmalloc_array() is safe against arithmetic overflow of the arguments. >> Using kcalloc() directly we wouldn't check for that. Not really ideal in >> my opinion. And there's no kcalloc_array() apparently! > > But doesn't kcalloc() simply call kmalloc_array() with the GFP_ZERO > flag? > It does! Oops, I'll send it shortly Tomas