Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp216981ybi; Fri, 24 May 2019 02:44:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9ytEhLZ3d+1EzPnr6cPxAqT8Eia3cuT1tG4ZiDwmxV9piuTOtdcoyuSmvUQXVTIAvQl3O X-Received: by 2002:a17:90a:5d15:: with SMTP id s21mr7731528pji.125.1558691050842; Fri, 24 May 2019 02:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558691050; cv=none; d=google.com; s=arc-20160816; b=AbdVH+XVJHI1mme3fuWEoRTpyp/pjo1i8d2c5H7QgY0S+QP51rwYyFMEGy8HH8a+6S w90G6nZAXySOtx7NzuqIe76HTVn3eE7vov4qSD6ZbcOIk4DEhhzJB/lRZdxbaCSkm4vO ntx0t4kbvJ/CkbqBUdPQOf1vNrx7UVLM6jBZ8xfdp9ek2jlg1/obGzhWmMs1XRzrRsqj Cz8bymP+8IWct6fKuySm8u7i6ti38OJ8fnQbzKF0tP3BCgadIP+7YR8tQM3gS+Zf2+2+ TpkfeIG89y9J8idZWTGG/KmN9MR5q3V4zgmopR/RKtMCbpw4eDjruRZKEi3PPUgSN1Lk Vpug== 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=f+gDnXlt84op+cO+SWUow2VW/jdTpsnQIMrQpyyMGgg=; b=MwmNUIbxoxcWxrhMQTel9nPl6uSxRpAsWJBqtavgPg8sikQg0vlspVMtS1GL5t2G+A h22x3FhBw73PfBRBWXygdb2ZvUFulMuj1KO36J7I4j4KA8gO9oRdeTIMRgNnyfx3hglv I6tTXeaHtwkU6VMr7eBm6tFZ7IkwgUkey1g2anGY1c1Y7Ir40SVuJ66kGriW/pGg0jjO n/2II4QG9Y/9oplDIM05YuE8/prmlO4tFsBlijmru4/0bSRlHXXCnqNRVyCiGeO/swN0 fvARxN/jRpYjpSZSnsJLX3i6AI8aywtXYYa2c0/xR2I5aLW2J09r+hScwfN2eABuEWMz VtLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=IrJmjsCm; 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 cb3si3803037plb.89.2019.05.24.02.43.53; Fri, 24 May 2019 02:44: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=@nvidia.com header.s=n1 header.b=IrJmjsCm; 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 S2390240AbfEXJm3 (ORCPT + 99 others); Fri, 24 May 2019 05:42:29 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:18430 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389677AbfEXJm3 (ORCPT ); Fri, 24 May 2019 05:42:29 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 24 May 2019 02:42:29 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 24 May 2019 02:42:28 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 24 May 2019 02:42:28 -0700 Received: from [10.21.132.148] (172.20.13.39) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 24 May 2019 09:42:26 +0000 Subject: Re: [PATCH] spi: Fix a memory leaking bug in wl1271_probe() To: Gen Zhang , , CC: , References: <20190523143022.GA26485@zhanggen-UX430UQ> From: Jon Hunter Message-ID: <279050e0-39e4-173d-ffe8-c1837951f4d1@nvidia.com> Date: Fri, 24 May 2019 10:42:25 +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: <20190523143022.GA26485@zhanggen-UX430UQ> X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL103.nvidia.com (172.20.187.11) 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=1558690949; bh=f+gDnXlt84op+cO+SWUow2VW/jdTpsnQIMrQpyyMGgg=; 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=IrJmjsCmpX60wzUFmVgEp/9UJN9UZ8CYieGXNOttBYSl0DHZVc5tniuH7PieaTg0L cJXXy8DPE0qVjF1PnDEITchM8yIkJEFsYMapIUL9UsWWd+dMOtabN/lijwIuBZ3Jij Mu4J588ig4jERKcaDk7drT7tzEVEzG/U7TNC/zdCjRzUG8L90N+JypogQwWKx55x5Z YCxh4Y/K04ckhNUH8R26DDGms6OsVpA1sGDPrUn8bOnFCW9ryGsS0pSgO0b2FBQrKw aFumIbRFnHWe6UetgEZ9eC/5jqDNktD2ofYnSpMQWYZXu6qDRfXm4d4LRCN63HLRLc oOuMI+pveu4oQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/05/2019 15:30, Gen Zhang wrote: > In wl1271_probe(), 'glue->core' is allocated by platform_device_alloc(), > when this allocation fails, ENOMEM is returned. However, 'pdev_data' > and 'glue' are allocated by devm_kzalloc() before 'glue->core'. When > platform_device_alloc() returns NULL, we should also free 'pdev_data' > and 'glue' before wl1271_probe() ends to prevent leaking memory. > > Similarly, we shoulf free 'pdev_data' when 'glue' is NULL. And we should > free 'pdev_data' and 'glue' when 'glue->reg' is error and when 'ret' is > error. > > Further, we should free 'glue->core', 'pdev_data' and 'glue' when this > function normally ends to prevent leaking memory. > > 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