Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp4040771ybn; Fri, 27 Sep 2019 15:28:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXaeX4Dh1yY+4R6Z9iRgyNqv8ig6i4rgdOZ2oSbRmNMPgmj0YgmlSapomu0rxqsozU/KkO X-Received: by 2002:a50:f0dd:: with SMTP id a29mr7191536edm.219.1569623326343; Fri, 27 Sep 2019 15:28:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569623326; cv=none; d=google.com; s=arc-20160816; b=PnrWdR6kiGqLvv2xjHmgGoPfomH/4jNc133Cah3menufuOXqZ6d3HRb+iYE2d8PA6n 9ZaTHid5HqtFOZhAy5TSCtZngv3bRVNL7Jplk8bcMp+za37/JVdbSr10RCir8I/E+LDA +NqdcOva7nsfqVlYx3PilgvXb7aR7pvnDdGUcTtQ6whWwnBaVzpjtjfBOvMZz7BCBDFc pvl6O0LwmskB02GQIeJ5K39bTtiMZ/w5Lwk/B/OlvFonjajytbnYTUlI0E1jr3RA0OlM y9Awv8l72c4O8N7wC0d1IpaXAV+mJRsmQQrOomMLw/VYJ0SKkwt9zuRMCPdmO8f+VfTe IJ1Q== 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:from:references:cc:to:subject; bh=osLGY70g7RufVpH8AVrI7bLnwmA+7E4d7HO01iHd390=; b=teQTFpGbsJk3WBZmMCC0XRMPRT2WOYHCkrl3A5MfncW4DOI6dgi6XIoWwLaR5hMtPD A+KzhfytIYnRnbYUtOjaVNtXiTKCXgWdvTCpfBdoCCAOJTLmaZ3moEJc1bONSrhD8LPz Zjn1OmvH/OUlQEuniAx2GrVH0uSG9n4L0uWkZpp70Dtfu8JXU3yWpd/cgSGzWTJaJKSz 3OJbJ2+ksQ9jbb4ep8H1tbMafNRnBkxnuYRFbbPEZszTHWZ515awUHs4J/NvEbMwaXDg 8nu9i6FPfFN3t/vL2/Pq0ccVWlgbROZGho+z6pnBhjm1TYO6tVNjq8dwwCBtqZEaeLsO CRGA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a29si2531374eda.246.2019.09.27.15.28.22; Fri, 27 Sep 2019 15:28:46 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728463AbfI0WZm (ORCPT + 99 others); Fri, 27 Sep 2019 18:25:42 -0400 Received: from mga11.intel.com ([192.55.52.93]:43622 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728252AbfI0WZl (ORCPT ); Fri, 27 Sep 2019 18:25:41 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2019 15:25:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,557,1559545200"; d="scan'208";a="219948342" Received: from linux.intel.com ([10.54.29.200]) by fmsmga002.fm.intel.com with ESMTP; 27 Sep 2019 15:25:40 -0700 Received: from jastaffa-mobl3.amr.corp.intel.com (unknown [10.251.18.83]) by linux.intel.com (Postfix) with ESMTP id 23629580127; Fri, 27 Sep 2019 15:25:39 -0700 (PDT) Subject: Re: [alsa-devel] [PATCH v2] ASoC: Intel: Skylake: prevent memory leak in snd_skl_parse_uuids To: Andy Shevchenko Cc: Cezary Rojewski , Greg Kroah-Hartman , Jie Yang , ALSA Development Mailing List , Navid Emamdoost , Takashi Iwai , Liam Girdwood , Mark Brown , Stephen McCamant , Kangjie Lu , Thomas Gleixner , Andy Shevchenko , Enrico Weigelt , Linux Kernel Mailing List , Navid Emamdoost References: <20190925161922.22479-1-navid.emamdoost@gmail.com> <13f4bd40-dbaa-e24e-edca-4b4acff9d9c5@linux.intel.com> <20190927025526.GD22969@cs-dulles.cs.umn.edu> <6966df25-e82c-1abe-6a0f-ff497dcda23b@intel.com> <20190927153304.GS32742@smile.fi.intel.com> <2e8ef4df-9c5f-f6e0-23ee-32d3bc555330@linux.intel.com> From: Pierre-Louis Bossart Message-ID: <3428d5e2-3246-7e1c-cb4d-59351193e4de@linux.intel.com> Date: Fri, 27 Sep 2019 17:25:41 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed 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 9/27/19 3:39 PM, Andy Shevchenko wrote: > On Fri, Sep 27, 2019 at 7:39 PM Pierre-Louis Bossart > wrote: >>> The problem with solution #1 is freeing orphaned pointer. It will work, >>> but it's simple is not okay from object life time prospective. >> >> ?? I don't get your point at all Andy. >> Two allocations happens in a loop and if the second fails, you free the >> first and then jump to free everything allocated in the previous >> iterations. what am I missing? > > Two things: > - one allocation is done with kzalloc(), while the other one with > devm_kcalloc() > - due to above the ordering of resources is reversed Ah yes, I see your point now, sorry for being thick. Indeed it'd make sense to use devm_ for both allocations, but then the kfree needs to be removed in the error handling.