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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 199B2C4332F for ; Tue, 19 Oct 2021 22:30:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0136B60F8F for ; Tue, 19 Oct 2021 22:30:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229848AbhJSWcd (ORCPT ); Tue, 19 Oct 2021 18:32:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229835AbhJSWcc (ORCPT ); Tue, 19 Oct 2021 18:32:32 -0400 Received: from out1.migadu.com (out1.migadu.com [IPv6:2001:41d0:2:863f::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89404C06161C; Tue, 19 Oct 2021 15:30:19 -0700 (PDT) Date: Wed, 20 Oct 2021 07:30:07 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1634682616; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3eYlirUPJWlfZnDuhuK3/qZsVNkj8Tn2KKROW5g83xA=; b=lEGQDiuVrgN0IyPFKKxOVGyYWZoqRUnW+bUEsVWpJV7nXwQa7p74+yUOSZZ96Wf8T76Eno HVEiQZSTOqqZZdamYa3vlqmNuKb2oBiqKRJnHjxA28gxIxc9RJ9hYA8GtjQAMZGzrcKApd PaAMmc0ohdoMJ3ynOSzZH9buRxObENk= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Naoya Horiguchi To: Yang Shi Cc: HORIGUCHI =?utf-8?B?TkFPWUEo5aCA5Y+jIOebtOS5nyk=?= , Hugh Dickins , "Kirill A. Shutemov" , Matthew Wilcox , Peter Xu , Oscar Salvador , Andrew Morton , Linux MM , Linux FS-devel Mailing List , Linux Kernel Mailing List Subject: Re: [v4 PATCH 5/6] mm: shmem: don't truncate page if memory failure happens Message-ID: <20211019223007.GA2324358@u2004> References: <20211014191615.6674-1-shy828301@gmail.com> <20211014191615.6674-6-shy828301@gmail.com> <20211019055221.GC2268449@u2004> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: naoya.horiguchi@linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Tue, Oct 19, 2021 at 10:29:51AM -0700, Yang Shi wrote: > On Mon, Oct 18, 2021 at 10:52 PM Naoya Horiguchi > wrote: > > > > On Thu, Oct 14, 2021 at 12:16:14PM -0700, Yang Shi wrote: ... > > > @@ -2466,7 +2467,15 @@ shmem_write_begin(struct file *file, struct address_space *mapping, > > > return -EPERM; > > > } > > > > > > - return shmem_getpage(inode, index, pagep, SGP_WRITE); > > > + ret = shmem_getpage(inode, index, pagep, SGP_WRITE); > > > + > > > + if (*pagep && PageHWPoison(*pagep)) { > > > > shmem_getpage() could return with pagep == NULL, so you need check ret first > > to avoid NULL pointer dereference. > > Realy? IIUC pagep can't be NULL. It is a pointer's pointer passed in > by the caller, for example, generic_perform_write(). Of course, > "*pagep" could be NULL. Oh, I simply missed this. You're right. Please ignore my comment on this. - Naoya Horiguchi