Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp950053rwb; Tue, 29 Nov 2022 07:15:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf7tdJMgq0dy4tlCHj5Htyj57203I4jPdbgowIQI6IgW3tfeN5hOQqP1vLB2g9bvKLDPZrNw X-Received: by 2002:a17:906:bcda:b0:7c0:80b0:7f67 with SMTP id lw26-20020a170906bcda00b007c080b07f67mr5300161ejb.462.1669734921381; Tue, 29 Nov 2022 07:15:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669734921; cv=none; d=google.com; s=arc-20160816; b=dBUHCRRR47V0ksd0aTj9KYiwW8a1RF3r/UBvVpkMTJ+GW5nJvdiHc0Y+KzL1cvA/3L QY+6SzpxtdKCAq8zg7OKj1u/Kqco8k/i2xR5azlFS9p/gVFfio1UblE+L6bmth3in09g qNqXAjonKsmnMhBhvGjCjyr2j4IlJ6nZEvaKCvW7BWJrPL8FoLUveyTQiKP5H80953Vg cbZt85BZdTtKEJFdU+7BjyvjEa/NC3mohVlRxT6l4HMst6tS0U4BXKq33G6g/dCuvc5z Sm5z8M52JTUG5ixmB548Un6tZYbnDn/WiSFuaoAlFEpxbiWQryUUdBFOPOdaONEEOjMR 0+RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=pApn4qCCRR4myxRZicgNT3gB5Un11uVMzKMNfa1etJs=; b=qCrddB6+QepEaiGtVSjj2qLPUa7zAt5j6bOnPJ6EmoMTx81DZ3wHweiiadVGBITKbU wcELxMllr2wj9+5x5nOFFp36uxYBY+HZpFeHQ2Y2QJKSiLcbD6/HU0WrBHRD252a4Q5q ZNawAxGMmHYh/EeLTv1roGauxy3uNkfZrYsYyk3e33IA0GJFGiEjbV68jWzVnyhV6TpR PwDnq0NfkuMur7CX4Suruyvh7dQbUGHQY6qJOOtSdTwr1WrKZGKUAGHLTFzUT4ZHgYvo ltkxhxdlw6aMR57FSxRJpfJKhXHFfo9XA+4NLVjTLcQRCwmn12oeDh16R21w2Mf4vwY1 Ryug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs17-20020a170906dc9100b00780def41dc4si12608718ejc.527.2022.11.29.07.14.56; Tue, 29 Nov 2022 07:15:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235759AbiK2O4e (ORCPT + 84 others); Tue, 29 Nov 2022 09:56:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235779AbiK2O41 (ORCPT ); Tue, 29 Nov 2022 09:56:27 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FF4F5F8F for ; Tue, 29 Nov 2022 06:56:26 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BE7F96179C for ; Tue, 29 Nov 2022 14:56:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55648C433C1; Tue, 29 Nov 2022 14:56:24 +0000 (UTC) Date: Tue, 29 Nov 2022 09:56:20 -0500 From: Steven Rostedt To: Andrew Yang Cc: Masami Hiramatsu , Matthias Brugger , Casper Li , , , Subject: Re: [PATCH] mm/writeback: fix dereferencing NULL mapping->host Message-ID: <20221129095620.4c1a8056@gandalf.local.home> In-Reply-To: <20221129033304.4465-1-andrew.yang@mediatek.com> References: <20221129033304.4465-1-andrew.yang@mediatek.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 29 Nov 2022 11:32:59 +0800 Andrew Yang wrote: > From: "andrew.yang" > > Check before dereferencing mapping->host > > Signed-off-by: andrew.yang > --- > include/trace/events/writeback.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h > index 86b2a82da546..56f6e114d3ed 100644 > --- a/include/trace/events/writeback.h > +++ b/include/trace/events/writeback.h > @@ -68,7 +68,7 @@ DECLARE_EVENT_CLASS(writeback_folio_template, > strscpy_pad(__entry->name, > bdi_dev_name(mapping ? inode_to_bdi(mapping->host) : > NULL), 32); > - __entry->ino = mapping ? mapping->host->i_ino : 0; > + __entry->ino = mapping && mapping->host ? mapping->host->i_ino : 0; I hate remembering precedence. Can we add parenthesis around this to be clear? __entry->ino = (mapping && mapping->host) ? mapping->host->i_ino : 0; Thanks, -- Steve > __entry->index = folio->index; > ), >