From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F13EC433E7 for ; Mon, 12 Oct 2020 08:11:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C64ED208B6 for ; Mon, 12 Oct 2020 08:11:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hooBfwk+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C64ED208B6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DCA24940008; Mon, 12 Oct 2020 04:11:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D52ED900002; Mon, 12 Oct 2020 04:11:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C23CB940008; Mon, 12 Oct 2020 04:11:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id 89D9E900002 for ; Mon, 12 Oct 2020 04:11:35 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 26BCA180AD807 for ; Mon, 12 Oct 2020 08:11:35 +0000 (UTC) X-FDA: 77362554150.09.honey42_37172a5271f9 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 0CFF2180AD806 for ; Mon, 12 Oct 2020 08:11:35 +0000 (UTC) X-HE-Tag: honey42_37172a5271f9 X-Filterd-Recvd-Size: 4598 Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Mon, 12 Oct 2020 08:11:34 +0000 (UTC) Received: by mail-ej1-f67.google.com with SMTP id h24so21923110ejg.9 for ; Mon, 12 Oct 2020 01:11:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=reply-to:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=M1NhPSK8WcpTtZeyW8ggYwirkBLqPyAO/qcKCJS3Ci0=; b=hooBfwk+2I80d0Ms8XxtPp3CfKDIx3enCApEOuuytF3Anb8bHKoLNqZfbtlJbU56Hb yNwF7zdbzJAkZQVna9Si5mcidbKO5VoSKaNZpmIZIrXhFaGg0IHkXmRwRBHAoGB1ddD9 ZKw3QjFBs+o7tQRDviU6aBtv/ckgsVeO558kbxdQAJXW1toWHTWlxDplYsvVyD2f/odt i/g0Botby3AkC2oTpABiBaKl/jcVCDz9nRj9CqvSQ8rBj7gVuIpkRNy85vuRePFfd4Rp cBlY/IUcu4KNrcgO3at/VEVS6tfMIxZ6VUZRaJBSrNxFxh53vobe1uI/OhZJbjdkg32x Y+cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=M1NhPSK8WcpTtZeyW8ggYwirkBLqPyAO/qcKCJS3Ci0=; b=O+nhMmZGElRhwgr/4gg9vb9yp/f0lqCtPPLQBcM54pIjoTEKb2UyaRR8FTwthXsapa lnmJk4Dbk1WBTxhMjBbiN4bPIieSzWWyaTjhShYpfyCXvr6rBz+QirAWCke9kGdSPKIu r3WX9bUZsJwtMXrYRMemNsvM9kZsKMpEijEPSYR3s1XnGkNize8pWS0b+qMgCeXHh/5x SUx4As727JY8SqgPrXWr9ckVaQY44/CzkEvPE7X7bceJDe4sfudG5oBzgo+3M08uhlk9 cbQMMhSHg98GTSNYHfaCZz9J4ukRlw03fKkJJqMRWSfRoheFCSW8mTwWoTW5ZihGHqCp 45JQ== X-Gm-Message-State: AOAM530cuFlIrxnHgFpXkvAnSQ4L7pRd6YeO7e+vUvbw3HNmVM3Vt3Vl 0v0/d09kLzqVbnRriShj5fs= X-Google-Smtp-Source: ABdhPJweeE2yP6VxtQZod6lD2VKbJ5vhzDztVRMAHk7/HnG5S/RU3E8nwHmSCPtcnJZtER6cRV0qzw== X-Received: by 2002:a17:906:53d7:: with SMTP id p23mr26383911ejo.232.1602490293318; Mon, 12 Oct 2020 01:11:33 -0700 (PDT) Received: from ?IPv6:2a02:908:1252:fb60:be8a:bd56:1f94:86e7? ([2a02:908:1252:fb60:be8a:bd56:1f94:86e7]) by smtp.gmail.com with ESMTPSA id j18sm10177649ejc.111.2020.10.12.01.11.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Oct 2020 01:11:32 -0700 (PDT) Reply-To: christian.koenig@amd.com Subject: Re: [PATCH 2/6] mm: introduce vma_set_file function v3 To: Jason Gunthorpe Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, chris@chris-wilson.co.uk, airlied@redhat.com, akpm@linux-foundation.org, daniel@ffwll.ch, sumit.semwal@linaro.org, willy@infradead.org, jhubbard@nvidia.com References: <20201009150342.1979-1-christian.koenig@amd.com> <20201009150342.1979-2-christian.koenig@amd.com> <20201009151418.GW5177@ziepe.ca> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <9592e3da-a105-b0ec-3fb2-be349c464c2c@gmail.com> Date: Mon, 12 Oct 2020 10:11:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201009151418.GW5177@ziepe.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable 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: Am 09.10.20 um 17:14 schrieb Jason Gunthorpe: > On Fri, Oct 09, 2020 at 05:03:38PM +0200, Christian K=C3=B6nig wrote: >> +/* >> + * Change backing file, only valid to use during initial VMA setup. >> + */ >> +void vma_set_file(struct vm_area_struct *vma, struct file *file) >> +{ >> + if (file) >> + get_file(file); >> + >> + swap(vma->vm_file, file); >> + >> + if (file) >> + fput(file); >> +} > fput crashes when file is NULL so the error handling after > unmap_and_free_vma: can't handle this case, similarly vm_file can't be > NULL either. > > So just simply: > > swap(vma->vm_file, file); > get_file(vma->vm_file); > fput(file); > =20 > Will do? I was considering this as well, yes. > Just let it crash if any of them are wrongly NULL. Mhm, changing from anonymous to file backed or reverse is probably not=20 such a good idea. So yes catching those problems early is probably the best approach we=20 could do. Going to do this in v4 if nobody objects. Regards, Christian. > > Jason