Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1466632yba; Fri, 26 Apr 2019 23:31:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGYlrKi36t8dUO3znM+t917zadLD+V9OScJbbNPRZFaq91O1Chb01XM5uiMzf7E5WHOQ0s X-Received: by 2002:a65:6110:: with SMTP id z16mr39400016pgu.131.1556346688103; Fri, 26 Apr 2019 23:31:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556346688; cv=none; d=google.com; s=arc-20160816; b=ImWBjk9Q6SvVaMoCbwGgF8gbUXmQwMQ4bbQwZNFkBHbyMNqJZceLQDgmtEi4WS3cdg LvPDUD/iMXP4+P/cRw5vAgKQyAMOhx96oYTrdaB2kITn71HzTe4/XoGNZzx2B2S4aEw+ c+VRm6nJLFk5VKAZr2cQK58QfMypmSBNE07PO2PDCPvSOCYa+tnDMH529zhKAsr4eWe8 7tzi7w34xQvKotq49xmLsv36HSotpNJb0gEiqs1VOluytzUU1P8Cu4MeJKZuyJZ9aXyt 5HSR6KnQpBQInhEUGACe0ScgpiJGUfoCyuVctAgN75EYC2V4b8llhR2eejT1k+qg2WNX BOTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=2u3EwjWwXV67Bz4LM1eTbvzs6VRx/8lQZrbrqWRWzeQ=; b=FMpbuSsAt7/vZJmTciSmbu5so+SqJ5pcaZwMl+2ctTe3uoiggWYYYtvWOsw4iE3cCM EGAG5yfWa8bPaWReh2N28X9G2xHh1O2IGGhXVRUYzH32JQWtbsppIElGWS1uiAR/Njzs A4FqT14G1lH3zasJJhEnWFo1es8h0RSzY0vCS2jutaa3M+EnuvMJKzz4QLVETLlQO8X6 WokCG5jEEVvKLw+gUKxs4L5a0cBq0zfgewz/NwpVIyX8WeMCbqE0o0opDLxDBidYkDAc HDoxMCMGiNkR9G6DzBYPakB1433rybchRE0/i5/LH46NpxNxV6qFxM68TwlHUzloRgX5 1vmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=A4h7Igia; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h25si24710691pgv.244.2019.04.26.23.31.12; Fri, 26 Apr 2019 23:31:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=A4h7Igia; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726181AbfD0GaW (ORCPT + 99 others); Sat, 27 Apr 2019 02:30:22 -0400 Received: from conssluserg-05.nifty.com ([210.131.2.90]:64303 "EHLO conssluserg-05.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726030AbfD0GaW (ORCPT ); Sat, 27 Apr 2019 02:30:22 -0400 Received: from mail-vs1-f45.google.com (mail-vs1-f45.google.com [209.85.217.45]) (authenticated) by conssluserg-05.nifty.com with ESMTP id x3R6U6Wo000593; Sat, 27 Apr 2019 15:30:07 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-05.nifty.com x3R6U6Wo000593 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1556346607; bh=2u3EwjWwXV67Bz4LM1eTbvzs6VRx/8lQZrbrqWRWzeQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=A4h7Igiam7BnsZkAcw2zeoGCJPVRLE68S1zGfFDpQteSlxy/bR02EIL8KTBcrrPP6 yIKBMoDHl2Dmdpkkhm0CAKDuEjsAdJAqV29J6lvoD0sYvl5B4vkhjTh9Q/29yzFv7T CvZkjEGM6F7WRS88fTHN72vTiOPvZoX3Ukv7admE4iYPUKjkr28dAhw7TX7sfXW9kh TZ6rASNE+XFb+UlpPwhxcTCcGR2q3tuQdU/UUBZkL9TZjUjFJxaO2rZ/9yETkNr+RA blXCzQqMraBj3yQMtVEA0/VS/0G2GHngqPTCA4zx8VvTR8kLRtk/EQCFroAf8NJqZa 5VjBKlq2jopUw== X-Nifty-SrcIP: [209.85.217.45] Received: by mail-vs1-f45.google.com with SMTP id s11so3221808vsn.0; Fri, 26 Apr 2019 23:30:07 -0700 (PDT) X-Gm-Message-State: APjAAAUdZr6FvssrmuzTtwBcYqCS8kGhmBOBtkUv/PzwofF836N8yiNJ AkYV54JaefYJaFeEYx45LOq8vhxhkCIV48RD99M= X-Received: by 2002:a67:ea89:: with SMTP id f9mr15571145vso.179.1556346606256; Fri, 26 Apr 2019 23:30:06 -0700 (PDT) MIME-Version: 1.0 References: <20190426222237.13209-1-colin.king@canonical.com> In-Reply-To: <20190426222237.13209-1-colin.king@canonical.com> From: Masahiro Yamada Date: Sat, 27 Apr 2019 15:29:30 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH][next] unicode: fix dereference of a potentially null pointer To: Olaf Weber , Gabriel Krisman Bertazi , "Theodore Ts'o" Cc: Michal Marek , Linux Kbuild mailing list , Colin King , kernel-janitors@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Forwarding because this file is not in my tree. On Sat, Apr 27, 2019 at 7:22 AM Colin King wrote: > > From: Colin Ian King > > The pointer 'tree' is deferenced when assigning pointer 'trie', however > trie is being null checked a few lines later, so it could potentially > be null. Fix the potential null pointer dereference by only dereferencing > it after it has been null checked. > > Addresses-Coverity: ("Dereference before null check") > Fixes: b08fcacaaaf4 ("unicode: introduce UTF-8 character database") > Signed-off-by: Colin Ian King > --- > scripts/mkutf8data.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/scripts/mkutf8data.c b/scripts/mkutf8data.c > index 12ce94b43be6..0563ba679bbb 100644 > --- a/scripts/mkutf8data.c > +++ b/scripts/mkutf8data.c > @@ -2706,7 +2706,7 @@ static utf8leaf_t *utf8hangul(const char *str, unsigned char *hangul) > static utf8leaf_t *utf8nlookup(struct tree *tree, unsigned char *hangul, > const char *s, size_t len) > { > - utf8trie_t *trie = utf8data + tree->index; > + utf8trie_t *trie; > int offlen; > int offset; > int mask; > @@ -2716,6 +2716,7 @@ static utf8leaf_t *utf8nlookup(struct tree *tree, unsigned char *hangul, > return NULL; > if (len == 0) > return NULL; > + trie = utf8data + tree->index; > node = 1; > while (node) { > offlen = (*trie & OFFLEN) >> OFFLEN_SHIFT; > -- > 2.20.1 > -- Best Regards Masahiro Yamada