Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp206118ybi; Fri, 24 May 2019 02:32:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnu/3cVfeJAsp5W5aDl2uYs64LW1OMrFaRMa2XRzS7Tji+kPG1HYlgOOY4FUGACuUBefiH X-Received: by 2002:a63:4c06:: with SMTP id z6mr102298056pga.296.1558690337294; Fri, 24 May 2019 02:32:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558690337; cv=none; d=google.com; s=arc-20160816; b=FATMD/4ZcHa3D+TrnzdkwlUD7tWneu0QkldKXSamBBhLqO6DBkv7IHSP9Sw0Led+Wy h3AWVPK8NpjJt/skKRhtPudJ2pAIZhATbdc11U92o/dLgC13ufc3QFXfvPIzHhLvy6M6 x4mJFfjayVWFQTkqEzfLcxQNAhG2/7HPYYLL8k2UoYz3ArTqzNsR+hRXtGd9ZOZk3hqx nzt18zukYWDEPJAK/df7mN07i+QmKX0V5yyy0hZ07GGKChqZw/5e3s/pyBKTGeV3X0YE sk/eLNH1nj4cckptLsP8FsblXVe7sIjYSIF5cGTIZzCNwn3NTdFPGF5vrpKI/jfVpsM4 60Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=w7pLj2lJsq63RcVDdYEsNgQk2low9PPUZap3YYWNh/g=; b=zgWJ/WK4eSVGwahFHAxloDuP7Jb7wGlIKH/Yw70ihgyyeEq0X8A2AKiMKlEOnAx1za EQIZ7oNH/ThLCtdA1F8SYe3M2qIQTwYzIDstZD84h+1FpdTcEpyZ/UQyze7uQF4bPyCI eHSuNTqjhb8o+F0ILmZTb4YES0GgOXqDt8XalAqi+xok5iW8fKGQ1j5+4Hke1hi6xXOP jiZIEobvqqlq6dveVn0tIjrXe7fbeOKUE20vt9M15zthMVxD/DxcaoEaBg62pzDNAq25 8u9CNtjQ7H8WQhIj+TGJvhsWd+V0cZA9EEsCQkrGFapMIYQD8V2LBn3ZCxX0bh+3bjrn MaJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=GDQKpbEI; 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=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j23si3136790pfh.215.2019.05.24.02.31.58; Fri, 24 May 2019 02:32:17 -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=@nvidia.com header.s=n1 header.b=GDQKpbEI; 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=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390079AbfEXJaN (ORCPT + 99 others); Fri, 24 May 2019 05:30:13 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:4769 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389582AbfEXJaN (ORCPT ); Fri, 24 May 2019 05:30:13 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 24 May 2019 02:30:12 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Fri, 24 May 2019 02:30:12 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Fri, 24 May 2019 02:30:12 -0700 Received: from [10.21.132.148] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 24 May 2019 09:30:10 +0000 Subject: Re: [PATCH] pcm030-audio-fabric: Fix a memory leaking bug in pcm030_fabric_probe() To: Gen Zhang , , CC: , References: <20190524021221.GA4753@zhanggen-UX430UQ> From: Jon Hunter Message-ID: <0fb5b294-99ba-bb73-a972-e1886dc6b792@nvidia.com> Date: Fri, 24 May 2019 10:30:09 +0100 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: <20190524021221.GA4753@zhanggen-UX430UQ> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1558690212; bh=w7pLj2lJsq63RcVDdYEsNgQk2low9PPUZap3YYWNh/g=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=GDQKpbEIpRwC1xcUjvHajuI7CDlbwtFrYQzarWn9yc/JoVLo6g2ETuoiNWO34Cmqt aEQ7HHNL3f0qR5fnmTuEHuoDCnV7yzQcB4KedjBSUHjTfcJfFTAIhi80hv3KHuLgHI hp+ViKhAU9nAGaPaEbxkg111HDy4eXAo8O/XHqJx4qSCB94TzJwcCaYR+4ZMDWromQ tHoe1FpAmaZC+htMSX6vpXsxbhLVRo2NcnUXe3+zox/U1zCTEjEvEBHyuHU/RgjfCc K2iS+kIDya/HiZ80DR1rtTWIA76hF0146gtKPQMarw8y6PN521/E1XCg9rlD1A+vKO /cjAIXeJRRMKw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/05/2019 03:12, Gen Zhang wrote: > In pcm030_fabric_probe(), 'pdata->codec_device' is allocated by > platform_device_alloc(). When this allocation fails, ENOMEM is returned. > However, 'pdata' is allocated by devm_kzalloc() before this site. We > should free 'pdata' before function ends to prevent memory leaking. > > Similarly, we should free 'pdata' when 'pdata->codec_device' is NULL. > And we should free 'pdata->codec_device' and 'pdata' when 'ret' is error > to prevent memory leaking. > > Signed-off-by: Gen Zhang I have seen several of these patches now, and this is not correct. I think you need to understand how devm_kzalloc() works. Jon -- nvpublic