Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3566532pxy; Mon, 26 Apr 2021 04:58:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKcKgd4c5SNGPFvpIizzH3oYfEb7c6j5gi4wiSkRmAaS1BpEPMMzDMl8pGrLmyIXWTQ5H7 X-Received: by 2002:aa7:8b0f:0:b029:20d:1b60:e823 with SMTP id f15-20020aa78b0f0000b029020d1b60e823mr17185411pfd.16.1619438322056; Mon, 26 Apr 2021 04:58:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619438322; cv=none; d=google.com; s=arc-20160816; b=k1IRiKAtr1Z80pjNPYHAbuBb9meW+sHfwDqLOD48KaqPGezRkQdt16LdSttUqCxXZQ 3uxFzV9EHmhu+GQhZwJrpFa1rC9hSL2h7sC6B1NWslL/IQD4LCEtbipHmzNvG9KAvd25 VoWwtKVVJIBSCuQhd92RzfOL/mUXpo/dg972TLTG+MC//UgVm0unKAJvGtZaP4wIqydN kI6r9GtaZz2mRb2DFRkEr/1joiZELL2XqHrTSjIu22AtaWEkZ0DkrVzs15/JC75HKb9R P7fxx1k9QtcsBYY0MNPtRNmZPRRYnF2/qaG5Ez/DYbbVPTQNT8DtegDbZaGPZMm1OLr6 l2Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=YBKtnrfj870BpoCUOQjiddIh7BY+km8BeX1vkFj0/xI=; b=NPDxi+jMuLivMdXrmmPs+GnT52SxodK7ZgiVnvAWmVSmysb+Hpd4oczcIXwhLSTJ0i PbYy2NRvPJV9iY09DwL5FQMFz5RWMfdanhAAlREJ2HOlfCnsCjpiO4pK/RUsH4ssP0du 6suNlv+aGKerHmIXAok9xFjF532TlR57fCEMcwblP1wo9aEJUUguBK9b2GyazxfjYDi7 wMg7Ka9jDV0V736m7Aer6UmF8LbWzE/kaTPnYtATQHAkWzc4oFfX5lFJWOH8JijpPRiH xHcaHQ1BwrYt+6pe81WW1IrQeqZ4a7pzLdcuPogj9SuMXcS0uRRCZZpBoQocEu9PWfey KiDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cJ9ZWmar; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t7si19419691plg.18.2021.04.26.04.58.30; Mon, 26 Apr 2021 04:58:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cJ9ZWmar; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231876AbhDZL6e (ORCPT + 99 others); Mon, 26 Apr 2021 07:58:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232520AbhDZL6e (ORCPT ); Mon, 26 Apr 2021 07:58:34 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5026AC061574; Mon, 26 Apr 2021 04:57:51 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id z13so6848571lft.1; Mon, 26 Apr 2021 04:57:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YBKtnrfj870BpoCUOQjiddIh7BY+km8BeX1vkFj0/xI=; b=cJ9ZWmarhUhMg1ePPcEAr0KgjhmQctpIGQQm4MOJfCv2ab64ezHhOFOFviKOZi3T8c eufBi1WOYutCMn+pTxJiwg/oxyZR8yzbbq9WkYnmSwVCCw4q5JMVhUQTOCUiHqnNOX+Y K5t/FXd7UkjnhYeTs6CCPN8bTjRltQnn8ffNW9pKF/Zlj3GkpeczbsVMzN7zstgojKF5 HjfHa7qf7t7VPGiSpFWCBi5mzao5Jmh7engnEOS5/zZtzPPEcqy5G6tBkSg5aRA7Surx t7a2EQMPcq9Nu6ifZtSewfzT+3wCFwgrbalOyicfSCZ2UkqSzbDc5J2W+NjnDC/mTyMJ k6Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YBKtnrfj870BpoCUOQjiddIh7BY+km8BeX1vkFj0/xI=; b=HKmxslB/PmAE9GXARQ4vq/4nDHGSQBlSRp+5LFHLXDEpCznr21y0yuDiHKJOdIkxcD eQvhzh5OtYD6TXZuU2xSMI+81X1LqjXchwAc7CxgSEYWRCoiU/lD/rU0NBbs/cm1TcUY +A0t2F08mdNlWekGKu1gAOvraoz0GE9YOUDtKMMbp+zetDo7LWMqxkwBFUEv/iuHUBf1 kt3eOIs2u90r4tFg7zzG5rMsJ5O12cK/92egBw0bOvUxTMfPtwItyI9JVzjsL9IAOMl9 lBRQuz37yr8tBiaS+XYfsAlN5h8aMHk5zLiNWAUXtC143NotyiJkWi+yMl2YAi0BaqNU i4Jw== X-Gm-Message-State: AOAM5309pyCQm9KMVCJEj+fo84ATRcGqdLBcLCtU8auYRKwhyvNlJzbR v/2yIH70qVhXs1iBS2h1Mz9ovopNAZIROWF78XKGNivOQCw= X-Received: by 2002:a19:50d:: with SMTP id 13mr12270824lff.443.1619438269845; Mon, 26 Apr 2021 04:57:49 -0700 (PDT) MIME-Version: 1.0 References: <20210426074935.11131-1-sherry.sun@nxp.com> <20210426074935.11131-3-sherry.sun@nxp.com> In-Reply-To: From: Fabio Estevam Date: Mon, 26 Apr 2021 08:57:38 -0300 Message-ID: Subject: Re: [PATCH 2/2] tty: serial: fsl_lpuart: fix the potential bug of dereference null return value To: Sherry Sun Cc: Greg KH , "jirislaby@kernel.org" , "linux-serial@vger.kernel.org" , "linux-kernel@vger.kernel.org" , dl-linux-imx Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sherry, On Mon, Apr 26, 2021 at 8:39 AM Sherry Sun wrote: > > > + if (!sdata) > > > + return -ENODEV; > > > > How can sdata be NULL? > > Is it possible that a case forgot to set sdata? Then the value will be NULL, such as { .compatible = "fsl,imx8qxp-lpuart", }. > So I added the patch to avoid the kernel crash when run to sdata->reg_off directly. But I am not sure does it make sense. sdata comes directly from of_device_get_match_data(). This driver only runs on DT platforms and the only way of being probed is when a compatible string matches, so it is not possible that sdata can be NULL.