Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp582397rwi; Fri, 14 Oct 2022 06:12:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4KLbIyIStL9Pnqei5CPzgeMEgtisrnPorp+ic3rxL64oPpVpnH+2YqbMX/GQxpoCuBVnTY X-Received: by 2002:a05:6a00:1a93:b0:565:b185:cc18 with SMTP id e19-20020a056a001a9300b00565b185cc18mr5116226pfv.70.1665753148977; Fri, 14 Oct 2022 06:12:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665753148; cv=none; d=google.com; s=arc-20160816; b=KrHX51BDWSAdFuXqhiEc7Vn7SFnnwswLoHpZ57rIaPiyJgR52xcUTEvzBFDwVFoFyH IHDNbrTRMHxoE0BvtWT79/YNd2vNh/wHOqG+B4IseoTj6xHhcNhS5wEDwGI8YNKzKXv4 CoNR+/T4v+movsMQuCRbifwldKu4czAkzGbFes1azD6EXhbb3Pgs3kmubzolzrttw5k1 FP3cI42FOQWfYxlO16DgkP/g//02IhfzTOI+TpavOnCKYlMEeBRZtp5qC6ZOVhvGY76o mK91FM995gVk321IBtpvvU2lVVbYu2siui2SdA2JK/GRy5oYY5n3aSrNBaxlnIDIWDZ1 slpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=e74pYK7vLx6IlOPOPqh+gX/TxdxGdVFG28XXhBE8NKE=; b=HkMdhgw+gi/5uZrkYM+7J43vGNTPiAy87W/DeUWEYYvkhBfWKjLVQCkk5Dsws50YoD vWgxWKwd9ALAS5MZtgZOMeG15d6AIu1tmu/junKAMPy94v9/yUZlEvmYSrQrTpx3YjAY +2V+DK927PizLtzYgMwUci1t0UaJdSIAeO/ZOeDARFaCI2Iodqi6rM0Kfc9Jlkr1jIEt azE1WUQbvVFlNp7/4JZZ+QJoRfaiHyP1kZFEwWcLtCBeerCcPnRLy6XpBKzwXJNp5IqU 7zLP+domub9NWMHZD/sonZemPE1ddDqW4y3eTuSXjf2YWDRwOHgBpTgZQDt8WgUoumGn ocgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=XpaTghU4; 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 h10-20020a17090acf0a00b00202c45a05basi8230014pju.73.2022.10.14.06.12.15; Fri, 14 Oct 2022 06:12:28 -0700 (PDT) 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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=XpaTghU4; 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 S229886AbiJNNDi (ORCPT + 99 others); Fri, 14 Oct 2022 09:03:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbiJNNDg (ORCPT ); Fri, 14 Oct 2022 09:03:36 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C8A11C8D7E; Fri, 14 Oct 2022 06:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=e74pYK7vLx6IlOPOPqh+gX/TxdxGdVFG28XXhBE8NKE=; b=XpaTghU4uz+r5xaUJJ/HBrjwdn 8IGOQXKHEe8ekuSVqZj+ZNdqGxMX7X2bSP4s4BtJ1OEgegaqQ4WrFUDaB90deADiF420PrzXb2M0i 8VTihJGTS1JRRRozSG9yevwcSrbvR0b4u7KcT3XSy+IzpMEIaVY8OBN4V4IhX0kEefs8oArnQ4/7s r0PMwWigDabkFAZRaeGjXL7Lw3YGXovPTv008a1H6Huw3GAOi9QesgVunlX7sh/vcAnHLcX+4G4Ni YIXvQ2LCgtGaN79MdvouF/uZJBebCMIW+4vphrYMXp/ho1VHku3rz7bxeH4IJfe/bkKVzn6SX/lxu 384EcPBg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojKLe-007dNb-Ln; Fri, 14 Oct 2022 13:03:34 +0000 Date: Fri, 14 Oct 2022 14:03:34 +0100 From: Matthew Wilcox To: Li zeming Cc: krisman@collabora.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] unicode: mkutf8data: Add malloc return value detection Message-ID: References: <20221014075710.310943-1-zeming@nfschina.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221014075710.310943-1-zeming@nfschina.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 Fri, Oct 14, 2022 at 03:57:10PM +0800, Li zeming wrote: > Add the check and judgment statement of malloc return value. Why? Just to shut up some static checker? > +++ b/fs/unicode/mkutf8data.c > @@ -495,6 +495,9 @@ static struct node *alloc_node(struct node *parent) > int bitnum; > > node = malloc(sizeof(*node)); > + if (unlikely(!node)) > + return NULL; > + Right, so now alloc_node() can return NULL when it couldn't before. Look at the callers ... while (keybits) { if (!*cursor) *cursor = alloc_node(node); node = *cursor; if (node->nextbyte) key++; They're unprepared for alloc_node() to return NULL, so all you've done is move the crash.