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 X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0B18C43381 for ; Mon, 1 Apr 2019 17:38:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 652FF20896 for ; Mon, 1 Apr 2019 17:38:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554140339; bh=WXWwGTtM5vR7HyMiqAler82wzus61PtCJhX6U8HwfdA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=IR4dTs3S4630Gj0jtlNblB0HyrkxHRss5iaDTRz1ssyH1NQ+BJDQetbgIoJUHJ8uF PAgbhwiFjgyVobNiSpwjmCiOxGVOT6gZK8fLdjJPfkKX/5tqEPKF1hznuzhly0Bfgl Pm8fpSN+GOOTUFbmG/4Xi+ioRiEnvGUwqu272G+o= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388377AbfDARi4 (ORCPT ); Mon, 1 Apr 2019 13:38:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:52324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388364AbfDARis (ORCPT ); Mon, 1 Apr 2019 13:38:48 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 981A72070B; Mon, 1 Apr 2019 17:38:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554140328; bh=WXWwGTtM5vR7HyMiqAler82wzus61PtCJhX6U8HwfdA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZJ0SoYY73AbPrYfYmR/YFq9xKF19R+2mZRxYmq0hnmKV7gPF/2nbPMTjFvD1a7Rz5 WsU4oj/8Rcn20zJzosG1btlTbf7s21m+6bIaVheH9ne15jmiMVBNk6Ujvvlps8ODoi 5uy4CFRYCjdlw2+F3kgxc7MlONq6kLcoHFWd5A9g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aditya Pakki Subject: [PATCH 3.18 40/50] serial: max310x: Fix to avoid potential NULL pointer dereference Date: Mon, 1 Apr 2019 19:03:23 +0200 Message-Id: <20190401170045.499690828@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401170041.257273804@linuxfoundation.org> References: <20190401170041.257273804@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Aditya Pakki commit 3a10e3dd52e80b9a97a3346020024d17b2c272d6 upstream. of_match_device can return a NULL pointer when matching device is not found. This patch avoids a scenario causing NULL pointer derefernce. Signed-off-by: Aditya Pakki Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/max310x.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -1321,6 +1321,8 @@ static int max310x_spi_probe(struct spi_ if (spi->dev.of_node) { const struct of_device_id *of_id = of_match_device(max310x_dt_ids, &spi->dev); + if (!of_id) + return -ENODEV; devtype = (struct max310x_devtype *)of_id->data; } else {