Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1643700ybt; Thu, 18 Jun 2020 13:42:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgVveiWS+FJRPGAIRlqfAB9+5dWhPstoQUOu9i2q+mlkl+vkFfNB4NCm8LV+lw9dv8r0yO X-Received: by 2002:a05:6402:148f:: with SMTP id e15mr55666edv.368.1592512950284; Thu, 18 Jun 2020 13:42:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592512950; cv=none; d=google.com; s=arc-20160816; b=jmrfa1cDSIpICQuEZkMsHb0+kXLY/j/mhDQ/4g6EOIDRjbXtKutyfRDJCG+3pmFvJM HYu2Y181Xy1ZTy9OKPBVH8CglVa3c8Di7GOsnEZ0Zn8SpoFjT4KBRVwlrjbQCwNJLa7y ZXSyOEakAJxNRgNHYTG0wPPNzEphLTcjl0iSdvXcNKSrDGeJSW5YN7lrvycsotcsdJ6q UwEGl08RQBA3qtbR/CK914Fg1GAowuknCYTc732RGSaaqw16Xl89NjA95YsRgsdIkQHZ tvh1vaCX4zCfv0eN0gm2hhbhxldn/8VxPw7ysC6/3BA5RIpyDuQ5IDAC69RIrZ2WT/Gp VJ9A== 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=0hMi0xIwkUC9/TCs8lWLufXqXDXyWYEohg3QmmYj+og=; b=CubtMrdWNtVwuLMDCnRbG61+aG9lllVnVCbq/uvnXbi+3B06cVl7HAWrmGviLoT3hk ueAS9CeekHaNEckf9uhSqPt0IXjkiI30PklGpB0mohOweb9XZN89TDXV4n7BWopK5dPR veB2LAJc8S98TUJZ1bbR1CobFvLp585Vwkkd11u5/91nP76Io4SWEMAEb2Yliwfcw5Ea eizlvNxuyxr8rswkqagzmoppsWbn4RlPkpMhBC2R8ibrBpHleebNDDCi1w4C9/6cT+AB Kvm1CIDDC91bR5LwLVoYd/QiBL0DoJ+cJILROZ+3PPD7TWlvDTLScssyo3jeCF37QN/H QKqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=BhqrUg2y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id y5si2537118ejc.674.2020.06.18.13.42.06; Thu, 18 Jun 2020 13:42:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@nvidia.com header.s=n1 header.b=BhqrUg2y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728729AbgFRQV7 (ORCPT + 99 others); Thu, 18 Jun 2020 12:21:59 -0400 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:11892 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726981AbgFRQV6 (ORCPT ); Thu, 18 Jun 2020 12:21:58 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 18 Jun 2020 09:20:17 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 18 Jun 2020 09:21:57 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 18 Jun 2020 09:21:57 -0700 Received: from rcampbell-dev.nvidia.com (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 18 Jun 2020 16:21:57 +0000 Subject: Re: [PATCH -next] lib: fix test_hmm.c reference after free To: Randy Dunlap , LKML , Andrew Morton , Linux MM CC: =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= References: X-Nvconfidentiality: public From: Ralph Campbell Message-ID: Date: Thu, 18 Jun 2020 09:21:57 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1592497217; bh=0hMi0xIwkUC9/TCs8lWLufXqXDXyWYEohg3QmmYj+og=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=BhqrUg2yERdAPawT5Qw+t1rBqdhQpLqbOV17quzsC/9rjv6aMSq/08gIKFAIfnzC8 fLNVgJUxCYmt4ODHApjKeW8X41saLfBstZnr4Mrt4ew6jwqzwgaN+FrEX5vZU0f+uv ytpvt9Al4dInIlHv1IrCulb0wIIf8W43P5VnQDmijbE5NBUfUi4pX+jx4V//Jqzs7y LGrHBOEfbwED/NLPnPRG4aBFm8CdNTDEp6VJ+/7FV+k7wYEj4a4KG+Ct+5I0nejD8N xl3wDHJIDbbszYz4XG3tQ+uYRCN98O8xMG3f23aTRMb/uWKphvTYTYNCuv7EHEikVx A+Ogz+qbUsoNA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/17/20 10:31 PM, Randy Dunlap wrote: > From: Randy Dunlap >=20 > Coccinelle scripts report the following errors: >=20 > lib/test_hmm.c:523:20-26: ERROR: reference preceded by free on line 521 > lib/test_hmm.c:524:21-27: ERROR: reference preceded by free on line 521 > lib/test_hmm.c:523:28-35: ERROR: devmem is NULL but dereferenced. > lib/test_hmm.c:524:29-36: ERROR: devmem is NULL but dereferenced. >=20 > Fix these by using the local variable 'res' instead of devmem. >=20 > Signed-off-by: Randy Dunlap > Cc: J=C3=A9r=C3=B4me Glisse > Cc: linux-mm@kvack.org > Cc: Ralph Campbell > --- > lib/test_hmm.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) >=20 > --- linux-next-20200617.orig/lib/test_hmm.c > +++ linux-next-20200617/lib/test_hmm.c > @@ -520,8 +520,7 @@ static bool dmirror_allocate_chunk(struc > err_free: > kfree(devmem); > err_release: > - release_mem_region(devmem->pagemap.res.start, > - resource_size(&devmem->pagemap.res)); > + release_mem_region(res->start, resource_size(res)); > err: > mutex_unlock(&mdevice->devmem_lock); > return false; >=20 Thanks for fixing this! Reviewed-by: Ralph Campbell