From patchwork Sun Sep 27 16:33:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Su X-Patchwork-Id: 11802215 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 CA65B6CA for ; Sun, 27 Sep 2020 16:33:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 608A723899 for ; Sun, 27 Sep 2020 16:33:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="iD/Q03s9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 608A723899 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=163.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 697C06B005C; Sun, 27 Sep 2020 12:33:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 622498E0001; Sun, 27 Sep 2020 12:33:43 -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 5378F6B0068; Sun, 27 Sep 2020 12:33:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0075.hostedemail.com [216.40.44.75]) by kanga.kvack.org (Postfix) with ESMTP id 3F2956B005C for ; Sun, 27 Sep 2020 12:33:43 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id F095D483C for ; Sun, 27 Sep 2020 16:33:42 +0000 (UTC) X-FDA: 77309387484.04.pet32_0d093c82717a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id D0ADF800CD0C for ; Sun, 27 Sep 2020 16:33:42 +0000 (UTC) X-Spam-Summary: 1,0,0,bdbf0f3d0e65eb19,d41d8cd98f00b204,sh_def@163.com,,RULES_HIT:41:355:379:582:800:960:966:973:988:989:1152:1260:1277:1312:1313:1314:1345:1381:1437:1516:1518:1519:1534:1540:1593:1594:1595:1596:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3868:3870:3871:4321:4385:5007:6261:6653:9592:10004:10400:10481:11026:11334:11658:11914:12043:12297:12555:12895:12986:13069:13311:13357:13439:13895:14096:14097:14181:14394:14721:19900:21080:21627:21990:30054:30070,0,RBL:220.181.12.13:@163.com:.lbl8.mailshell.net-62.50.2.100 66.100.201.100;04ygy949o3jzpj99wx57fn3wzgp8qyptx1eeowmmggkkchonmw193kc8ntisb7p.rqg51cp13zgmskdkitnueospkhbd61m6wypx6dkqtnsahichprjh85ojkkb4qta.s-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: pet32_0d093c82717a X-Filterd-Recvd-Size: 2320 Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Sun, 27 Sep 2020 16:33:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:Message-ID:MIME-Version; bh=dHBuV XudridnxqfNWPNN2oRSCii+hG0OIcSEYu/iFZ8=; b=iD/Q03s9Nsc7CIP50bSdo 1Rt0h/tdYxFRl+3bxG1ZLTBrU1aeYnjOasTI6my51QbjVggf+LXuSrzyJ0VAZ6X3 Mu2ootQbbvYjIIs5fyu7nwBzHDROi6EI5JK3s2YmlJiAQs4uTp2xsgjUTzwObCLh rZ5n9pMljmyQQ32wz6gZ5M= Received: from localhost (unknown [101.86.214.224]) by smtp9 (Coremail) with SMTP id DcCowABXpyvhvnBfM8AxIg--.47504S2; Mon, 28 Sep 2020 00:33:37 +0800 (CST) Date: Mon, 28 Sep 2020 00:33:37 +0800 From: Hui Su To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm/vmalloc.c: check the addr first Message-ID: <20200927163337.GA5472@rlk> MIME-Version: 1.0 Content-Disposition: inline X-CM-TRANSID: DcCowABXpyvhvnBfM8AxIg--.47504S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrZFWDWr43tF47uw4UWw47twb_yoW3trg_Ca sFkr1UXrWDJanrK3W29rs0vry7KFW0y3s29F13ta93Jry8GFWfGasrXr95JrW8WrW3XF9r W39rZFWxJrnxJjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU5GPfPUUUUU== X-Originating-IP: [101.86.214.224] X-CM-SenderInfo: xvkbvvri6rljoofrz/xtbBDgGsX1rbKaQU4AAAsE X-Bogosity: Ham, tests=bogofilter, spamicity=0.179016, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: As the comments said, if @addr is NULL, no operation is performed, check the addr first in vfree() and vfree_atomic() maybe a better choice. Signed-off-by: Hui Su --- mm/vmalloc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index be4724b916b3..1cf50749a209 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2305,10 +2305,11 @@ void vfree_atomic(const void *addr) { BUG_ON(in_nmi()); - kmemleak_free(addr); - if (!addr) return; + + kmemleak_free(addr); + __vfree_deferred(addr); } @@ -2340,13 +2341,13 @@ void vfree(const void *addr) { BUG_ON(in_nmi()); + if (!addr) + return; + kmemleak_free(addr); might_sleep_if(!in_interrupt()); - if (!addr) - return; - __vfree(addr); } EXPORT_SYMBOL(vfree);