From patchwork Thu Jun 18 05:31:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Randy Dunlap X-Patchwork-Id: 11611421 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 93E5F618 for ; Thu, 18 Jun 2020 05:31:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5760C217A0 for ; Thu, 18 Jun 2020 05:31:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="B9jhREfE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5760C217A0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5E5C96B0008; Thu, 18 Jun 2020 01:31:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 597BF6B000A; Thu, 18 Jun 2020 01:31:27 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AE076B000C; Thu, 18 Jun 2020 01:31:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0134.hostedemail.com [216.40.44.134]) by kanga.kvack.org (Postfix) with ESMTP id 2F8C56B0008 for ; Thu, 18 Jun 2020 01:31:27 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8F21C824556B for ; Thu, 18 Jun 2020 05:31:26 +0000 (UTC) X-FDA: 76941209772.18.seed58_19049a526e0d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 6B04F100ED3B1 for ; Thu, 18 Jun 2020 05:31:26 +0000 (UTC) X-Spam-Summary: 20,1.5,0,e8a9153412b6f3ce,d41d8cd98f00b204,rdunlap@infradead.org,,RULES_HIT:41:152:355:379:800:854:960:965:966:973:982:988:989:1260:1277:1311:1313:1314:1345:1437:1515:1516:1518:1534:1541:1593:1594:1711:1714:1730:1747:1777:1792:2196:2199:2328:2393:2559:2562:3138:3139:3140:3141:3142:3351:3865:3866:3871:4250:4321:4385:4390:4395:5007:6261:6653:6997:7576:7875:7903:10004:10400:11026:11658:11914:12043:12297:12438:12517:12519:12555:12679:12740:12895:12986:13069:13311:13357:13846:13894:14181:14394:14721:21080:21451:21627:21987:21990:30054:30064,0,RBL:198.137.202.133:@infradead.org:.lbl8.mailshell.net-64.201.201.201 62.8.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: seed58_19049a526e0d X-Filterd-Recvd-Size: 2793 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Thu, 18 Jun 2020 05:31:25 +0000 (UTC) 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-Language: en-US X-Rspamd-Queue-Id: 6B04F100ED3B1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Reviewed-by: 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;