Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1161048yba; Fri, 26 Apr 2019 15:23:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsnR2DqWoOwjbyZSP00TSJY2afOGUym7oxTv/y/XYdk+9zntn52KkLjwowV6WuFIqukRVg X-Received: by 2002:a62:e90d:: with SMTP id j13mr8274023pfh.42.1556317429474; Fri, 26 Apr 2019 15:23:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556317429; cv=none; d=google.com; s=arc-20160816; b=jNJdVr6J/fwJPJsuSzE+PnwlB5mb35Vl5UpYTt5opTHLA4c7NVu7nGOBa5OeIATTXt CYji1hDCydzDlSssqJlIrSR9SmI6ga9IdjbchxuwmQS+pqWMpOY97CNrJHUpQ1hHTAJd TmKEwrrireCRR/bq2QWTMIFysQ0qCtlQwDj2ExvrkOP2V7hZ23JVeJ4Joc+EQQJdOMIn PjyKfjujcF/WkWfEYoXWPZb1DBxMfl23g4ZyEBWy9jxC+uoxpI/0J5UvkjWDuImsnGSE B6K9hwvXxD/yQclJ7TtNjVnObBwpkboclRL/7CRtv/wriC8DOsHd4sWdg4vbNDprVDj3 IsKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=hKi8Q+ei4r81GZ1d+KZPxn/ZoZOTsaKNekC2WWV2bRQ=; b=ZtgkFMXP0hXEFbsGwBhOsq42tGQ51pNDATh2IKKiQA4ZMxZGhjDQNDEdGHCQITS6LR dyZT1UYXg83jXTCQAHJ/XIUnWQv0ixVEget+1Kmy8qloy+EJpMCBgo/ZHhFUpO3LaPAU cFMIZFC3LcIeIDkq3fQTMbTd1uFLF9ngyLLZSuDjTO2BDIXtF/FTdhFV3mI9LitOdyez GAy8Xuoa1lZU9rzxBdGhibOG1Jur87xUYX2glHKJ0/lEVC76ni4ETD9/l2UrtLqhTbJI ELKmMQbv796kynI22rIBv/8eHxI8IbAE6I/AdXKIAqj/F/I95dSucGlqj19yxuTHJhk0 0mOg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g33si25455388pgb.192.2019.04.26.15.23.33; Fri, 26 Apr 2019 15:23:49 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727061AbfDZWWo (ORCPT + 99 others); Fri, 26 Apr 2019 18:22:44 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:54552 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726871AbfDZWWn (ORCPT ); Fri, 26 Apr 2019 18:22:43 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1hK9Es-0002bw-2W; Fri, 26 Apr 2019 22:22:38 +0000 From: Colin King To: Masahiro Yamada , Michal Marek , linux-kbuild@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] unicode: fix dereference of a potentially null pointer Date: Fri, 26 Apr 2019 23:22:37 +0100 Message-Id: <20190426222237.13209-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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