Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1058924ybt; Wed, 17 Jun 2020 22:36:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw57sHIE+Zbe1NI45MMhiVSuGYisOzOc7Ob/toUhLbAS7INeGXbSVQ7/T3O5ffhPARnIyLw X-Received: by 2002:a50:d785:: with SMTP id w5mr2407947edi.212.1592458585835; Wed, 17 Jun 2020 22:36:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592458585; cv=none; d=google.com; s=arc-20160816; b=JvzESpH+AaOGQ63+ybnicD5ooR1/tJhT1YAQhu0OASo4qnmb3Rqdsh3+dpsp6EV4wm LiVVhCAfP7TUpIP4QGTB9zATcHfqrPw3d35rpB4jLysA40DIW0Mx113ssnvCZcQaRZGE YXJdC95WMZ/lkRtgcHKlF2k1NKfjKqUbwaIZSlihxBCw5RLExllZhek0wJMhzjb03dmP MVKPf43q2deUe9HO/p5Sji3D+yb/XAITcEEQkHQXaOV/ZMJgjG/ABcWEPVb0RzLkOesT hEsIKJSk+jQYxE2Ud2QFnlZ2KxNfxkCqPIRVOkcKWIp0vPuqaYcMZLP+ubKy4lmItZyI 2+ZQ== 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:mime-version:user-agent:date:message-id:subject :from:cc:to:dkim-signature; bh=j59LIKt0ZBQcjPYvOJ7LYaon1Ej4A1gLEpf436VqWNs=; b=BTJMK/RVufQO+Acqt2HuGyXjNhLnN7G9CAcxnV4TpCcK87jVM47RFbtqGPWatAhX3O NlQnE8sdpYkHSH4wVzkUuirL/bE4bJvsaaCd9G+iDSVYz0D7uHdQNtCjDnQRSRs/h1/U z8qy7HciBxzkM7KvkXEWNP1yABb/k8k7GvsIHv5CpFhp/uMbVTAppkI9/VfPaYe9gix+ PF1uVEARCE7lUEeuIF8dL9tk3RS5AXL4cGHe65+CWVt+nRp1uAQkk67kES87W34eUQrR yQDyvc1LwxM6BvZUqE/bTN8dPj0IMR6gm4JSTYdqvPDxUEPAz8V5Ndb1nvObLBrMBdsh HqEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=B9jhREfE; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lx2si1178209ejb.284.2020.06.17.22.36.02; Wed, 17 Jun 2020 22:36:25 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=B9jhREfE; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726952AbgFRFba (ORCPT + 99 others); Thu, 18 Jun 2020 01:31:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbgFRFba (ORCPT ); Thu, 18 Jun 2020 01:31:30 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C020C06174E for ; Wed, 17 Jun 2020 22:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:MIME-Version:Date:Message-ID:Subject:From:Cc:To:Sender:Reply-To: Content-ID:Content-Description:In-Reply-To:References; bh=j59LIKt0ZBQcjPYvOJ7LYaon1Ej4A1gLEpf436VqWNs=; b=B9jhREfEDVEPKppsrv5l3+GSyX NmO5I92C5oyvQRZ0R6/4dEJPMO4klMHZu03udlGfjPd99a9xBx5BwyJKmX8IeGOOOLVUr8xyMlGiC wTkPy+f5swuMFEjEfnbWBSNCr6+LZvdjYBLCQQKBbtZ62mNw/32aL0Ue+4yMrLAggsaRLXOXWD5Lx 3fNOkeMxXBIktbivYw6KvsJDOJR8+WwCIFCOPf16Ad+8tRJXklYeSAwjDoAbkX8JRByGy2ztHSKM8 uj5ZVv2uEM5giaVXlmYgnYp7u5JL6KH120HaEt8SnMdFapo3iHEm9Uy33pkpAmk+T68KVLAw0s4ji 7ZzI7kvw==; Received: from [2601:1c0:6280:3f0::19c2] by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jln91-0005Vv-9O; Thu, 18 Jun 2020 05:31:23 +0000 To: LKML , Andrew Morton , Linux MM Cc: =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Ralph Campbell From: Randy Dunlap Subject: [PATCH -next] lib: fix test_hmm.c reference after free Message-ID: Date: Wed, 17 Jun 2020 22:31:21 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Randy Dunlap Coccinelle scripts report the following errors: 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. Fix these by using the local variable 'res' instead of devmem. Signed-off-by: Randy Dunlap Cc: Jérôme Glisse Cc: linux-mm@kvack.org Cc: Ralph Campbell --- lib/test_hmm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- 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;