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=-2.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 B5B3DC11F6A for ; Thu, 1 Jul 2021 21:34:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F9D16140E for ; Thu, 1 Jul 2021 21:34:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234397AbhGAVhW (ORCPT ); Thu, 1 Jul 2021 17:37:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234150AbhGAVhV (ORCPT ); Thu, 1 Jul 2021 17:37:21 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50F9FC061762 for ; Thu, 1 Jul 2021 14:34:49 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id b2so12810655ejg.8 for ; Thu, 01 Jul 2021 14:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MPm2mNfDFAFz6LZYHsop45CBgdHBv6hIIQ/VkHD6NKA=; b=HvTjCzluEHCx88k64sQ1uGioAhhF0RaQdU2TKB3xXaeeJ5jaQe1vkBMflOMt0RMTxj iUISIublp8cNy2n9ZdkE02AYBeYCS1djQFxZvV2JGCHLdd66U9E93k7aFXQjQqUha4P3 gRpV2RfUVWOWwQM5VAi6Iu2tuUxgsZtntXjHLJShIQOabUWw5/yhZM1Hznq5fkfwfPTZ d4U5x2mx1wgy1/l9DweE/vR+RveLBfEcovXEnJY8gbgzymFvtwmSmPVP3Rez8GQQcZeO PrNXkGm5v0mrRayTQyy39K48MnsXAF9RU2041qhATMIe45TwPkFjClaj2ONRwj87cH9L cDgw== 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=MPm2mNfDFAFz6LZYHsop45CBgdHBv6hIIQ/VkHD6NKA=; b=YwkgzuKdKa1Pvbmk7qwtKwjOAXCuOffNAWJeZ25ygH+ARJR1kZAyfPWknkzsM4oCGG RyD1b+USX1YTXW3xx43vX8vFO+VLWmSwnmgp0BvP/6wgEUupMaN6h/DqZuYsi+QXoIV5 bBhHovDwjJQHKqe7ZbpJ0/ak20Yfs4vVYUjQPyTgaMxg+ZT71mFQVrYPeX+kvfHZlrUV j8IhAhJZyV4ag4sXCw64g6QcT34flya9Y1n9ROqVJ1LOzWChNGYTNJnIRUmLCE9wmoVA BFgXDGFeivDZr3AC/jke0W762vpS0TqwRv0SSRzDc0GbD99hCmEYxvWp4drQQli8toY4 Z6TQ== X-Gm-Message-State: AOAM532qXM57wco6kPsT53jPGnBloFsWQGwmu8DRSYGItuXqgEiW3cwK ztJow50jGwQM3Y2IvV+/6fbstZtoH0RKW4MVNC0= X-Google-Smtp-Source: ABdhPJyZ3ThStcILU2DEuZlK8i1r5iDZm7d/h/AfGai6wlTFHJI9KAhQtrkXuxM3Ic6DSOSfkN1YPmywHBMsDeqD97Y= X-Received: by 2002:a17:906:36d5:: with SMTP id b21mr2013027ejc.258.1625175287929; Thu, 01 Jul 2021 14:34:47 -0700 (PDT) MIME-Version: 1.0 References: <20210618052800.89007-1-jjcao20@fudan.edu.cn> In-Reply-To: <20210618052800.89007-1-jjcao20@fudan.edu.cn> From: Martin Blumenstingl Date: Thu, 1 Jul 2021 23:34:37 +0200 Message-ID: Subject: Re: [PATCH v2] drm/meson: fix potential NULL pointer exception in meson_drv_unbind() To: Jiajun Cao Cc: yuanxzhang@fudan.edu.cn, Xin Tan , Neil Armstrong , David Airlie , Daniel Vetter , Kevin Hilman , Jerome Brunet , dri-devel@lists.freedesktop.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, first of all: thanks for your patch and sorry for being late with my review question. On Fri, Jun 18, 2021 at 7:28 AM Jiajun Cao wrote: > > Fix a potential NULL pointer exception when meson_drv_unbind() > attempts to operate on the driver_data priv which may be NULL. > Add a null pointer check on the priv struct to avoid the NULL > pointer dereference after calling dev_get_drvdata(), just like > the null pointer checks done on the struct priv in the function > meson_drv_shutdown(), meson_drv_pm_suspend() and meson_drv_pm_resume(). I am trying to review Amlogic Meson related patches in the DRM subsystem so I can help Neil with this. However, I am still new to this so please help me educate on this topic. [...] > static void meson_drv_unbind(struct device *dev) > { > struct meson_drm *priv = dev_get_drvdata(dev); > - struct drm_device *drm = priv->drm; > + struct drm_device *drm; > + > + if (!priv) > + return; My understanding of the component framework is that meson_drv_unbind() is only called if previously meson_drv_bind() was called (and did not return any error). This is different from meson_drv_shutdown() (for example) because that can be called if meson_drv_probe() returns 0 (success) in case the "count" variable was 0 (then the probe function does nothing). As I mentioned before: I am still learning about the DRM subsystem in the Linux kernel. So it would be great if you could help me understand for which scenarios this newly added if-condition is needed. Thank you! Best regards, Martin 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=-0.7 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 A22DEC11F67 for ; Thu, 1 Jul 2021 21:36:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 607DF6140F for ; Thu, 1 Jul 2021 21:36:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 607DF6140F Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MalVewIX6tp/bGhQsF4jkOQwQdiXclPR/wQtOF7uJ7I=; b=nh+zTbr1zlG+9v rcyKj0XJotqMfTaCNfS0MuvDlt+QWgDjVc1CceQXH7WzCwbhs4vYgDgzI40jgqIIEuOnVPgCl3/lo z9XcqKtecAP9VdW81qJVhwgckb4Obx5melt/cO1qA+jY12fXEXQgEgKZh0nZnY4lpwQWSfm3GiA8o V+WBvFWgCo/Gh7+I/6FaiRsS+hkL0BeVux/1Btrzha16R1zWXtk2Z3dA+uzIQIxn3lIZbyM8r3VRj eFULdbB6V0ZEeKEVyz212wfomPEksBHb89zUSYAMZcAMTIFCCWAvWAVHrDCADcuJwWEO+M/CBGp0c N2yklxi1lFybr/vdKbYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lz4Kk-001DQl-SP; Thu, 01 Jul 2021 21:34:55 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lz4Kf-001DOU-S1; Thu, 01 Jul 2021 21:34:51 +0000 Received: by mail-ej1-x633.google.com with SMTP id o5so12807066ejy.7; Thu, 01 Jul 2021 14:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MPm2mNfDFAFz6LZYHsop45CBgdHBv6hIIQ/VkHD6NKA=; b=HvTjCzluEHCx88k64sQ1uGioAhhF0RaQdU2TKB3xXaeeJ5jaQe1vkBMflOMt0RMTxj iUISIublp8cNy2n9ZdkE02AYBeYCS1djQFxZvV2JGCHLdd66U9E93k7aFXQjQqUha4P3 gRpV2RfUVWOWwQM5VAi6Iu2tuUxgsZtntXjHLJShIQOabUWw5/yhZM1Hznq5fkfwfPTZ d4U5x2mx1wgy1/l9DweE/vR+RveLBfEcovXEnJY8gbgzymFvtwmSmPVP3Rez8GQQcZeO PrNXkGm5v0mrRayTQyy39K48MnsXAF9RU2041qhATMIe45TwPkFjClaj2ONRwj87cH9L cDgw== 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=MPm2mNfDFAFz6LZYHsop45CBgdHBv6hIIQ/VkHD6NKA=; b=eQDg/LzZoIvxkAWgoJJwuB17+0eY0vz9duycvjFaM0tsWjdJs6rIMJ5y2zGjf4jkRg gxqh22w4WyeTfiRR0ff9lmpq0+9tfz9ZYUEiquFUVTG9mGNKbPoAV9YoGqQiwCR6+52N b+fUFpGNznEQGbU1hP33wKgWxrPdkApdc8NUVMMenkAwUO8/7QEfSAv+55ca+3sF8UMi CTWgq5dymj3MDY4BbN4jxnrs9CkSPXkYSHjFnp5VPRhB+D57NLfeli8PKrL7cC7As4yk 5JDrUgwpKc1Alt3pJfX9SJXzB9ER5WG9QyoL9qxYFLRg0+QyBQCzUgGtG3Jb9jU69zp8 zTIA== X-Gm-Message-State: AOAM530HXUBoE3GtXiL12ir4/TkrB/bwZjWVUDWu9u3uX7XMjLtev3Jk IgI7C0WZY6BYVdP1cQrT0XU8Jc7+g2iL0M1SFAA= X-Google-Smtp-Source: ABdhPJyZ3ThStcILU2DEuZlK8i1r5iDZm7d/h/AfGai6wlTFHJI9KAhQtrkXuxM3Ic6DSOSfkN1YPmywHBMsDeqD97Y= X-Received: by 2002:a17:906:36d5:: with SMTP id b21mr2013027ejc.258.1625175287929; Thu, 01 Jul 2021 14:34:47 -0700 (PDT) MIME-Version: 1.0 References: <20210618052800.89007-1-jjcao20@fudan.edu.cn> In-Reply-To: <20210618052800.89007-1-jjcao20@fudan.edu.cn> From: Martin Blumenstingl Date: Thu, 1 Jul 2021 23:34:37 +0200 Message-ID: Subject: Re: [PATCH v2] drm/meson: fix potential NULL pointer exception in meson_drv_unbind() To: Jiajun Cao Cc: yuanxzhang@fudan.edu.cn, Xin Tan , Neil Armstrong , David Airlie , Daniel Vetter , Kevin Hilman , Jerome Brunet , dri-devel@lists.freedesktop.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210701_143449_970418_CE2E7426 X-CRM114-Status: GOOD ( 19.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hello, first of all: thanks for your patch and sorry for being late with my review question. On Fri, Jun 18, 2021 at 7:28 AM Jiajun Cao wrote: > > Fix a potential NULL pointer exception when meson_drv_unbind() > attempts to operate on the driver_data priv which may be NULL. > Add a null pointer check on the priv struct to avoid the NULL > pointer dereference after calling dev_get_drvdata(), just like > the null pointer checks done on the struct priv in the function > meson_drv_shutdown(), meson_drv_pm_suspend() and meson_drv_pm_resume(). I am trying to review Amlogic Meson related patches in the DRM subsystem so I can help Neil with this. However, I am still new to this so please help me educate on this topic. [...] > static void meson_drv_unbind(struct device *dev) > { > struct meson_drm *priv = dev_get_drvdata(dev); > - struct drm_device *drm = priv->drm; > + struct drm_device *drm; > + > + if (!priv) > + return; My understanding of the component framework is that meson_drv_unbind() is only called if previously meson_drv_bind() was called (and did not return any error). This is different from meson_drv_shutdown() (for example) because that can be called if meson_drv_probe() returns 0 (success) in case the "count" variable was 0 (then the probe function does nothing). As I mentioned before: I am still learning about the DRM subsystem in the Linux kernel. So it would be great if you could help me understand for which scenarios this newly added if-condition is needed. Thank you! Best regards, Martin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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=-0.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 DF4C0C11F67 for ; Thu, 1 Jul 2021 21:34:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE681613ED for ; Thu, 1 Jul 2021 21:34:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE681613ED Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2FCFC6EB4F; Thu, 1 Jul 2021 21:34:50 +0000 (UTC) Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4B36E6EC0C for ; Thu, 1 Jul 2021 21:34:49 +0000 (UTC) Received: by mail-ej1-x636.google.com with SMTP id bg14so12779278ejb.9 for ; Thu, 01 Jul 2021 14:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MPm2mNfDFAFz6LZYHsop45CBgdHBv6hIIQ/VkHD6NKA=; b=HvTjCzluEHCx88k64sQ1uGioAhhF0RaQdU2TKB3xXaeeJ5jaQe1vkBMflOMt0RMTxj iUISIublp8cNy2n9ZdkE02AYBeYCS1djQFxZvV2JGCHLdd66U9E93k7aFXQjQqUha4P3 gRpV2RfUVWOWwQM5VAi6Iu2tuUxgsZtntXjHLJShIQOabUWw5/yhZM1Hznq5fkfwfPTZ d4U5x2mx1wgy1/l9DweE/vR+RveLBfEcovXEnJY8gbgzymFvtwmSmPVP3Rez8GQQcZeO PrNXkGm5v0mrRayTQyy39K48MnsXAF9RU2041qhATMIe45TwPkFjClaj2ONRwj87cH9L cDgw== 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=MPm2mNfDFAFz6LZYHsop45CBgdHBv6hIIQ/VkHD6NKA=; b=WQ5yUjCnz88eZqEG9JynLLzfciWP4muLkO8mWwmxMl6dYuBSJfcrUbqotRw+MSGgLY Pse+4oFAnkNX3pY0uIO04UaSkqSjGGO5Al6QwxrgTURgDP0oJrLFTWsr210Tw3VH9Bzg O16RFqEg9rrvAL74VZ024Nl9BXhU8rHBiUKdm1qdNNdsZk+h2uL0RbdtKU8cgjUr1Vej DF6rc6SgRukzcqFBFIZKp3ezamHavqSY2r5MyINe1Qpmulb7NcgOtKIcSpMa1Fih2BDK FY9ctEzAcOWE+rcISAUJtCL57QcmtiRu8pWpxHQgXz5lQmZZUzGe8B2VGyP0xqI19Uo/ rUTw== X-Gm-Message-State: AOAM532EanXyCMBASpdIb3c56aysyQYXvqp6tN2ulbbjmr2K3t6sHVZh epXx8cSodMmnukGeL6s2bmv7EsblYLiuSDNX+SwXbyLHhww= X-Google-Smtp-Source: ABdhPJyZ3ThStcILU2DEuZlK8i1r5iDZm7d/h/AfGai6wlTFHJI9KAhQtrkXuxM3Ic6DSOSfkN1YPmywHBMsDeqD97Y= X-Received: by 2002:a17:906:36d5:: with SMTP id b21mr2013027ejc.258.1625175287929; Thu, 01 Jul 2021 14:34:47 -0700 (PDT) MIME-Version: 1.0 References: <20210618052800.89007-1-jjcao20@fudan.edu.cn> In-Reply-To: <20210618052800.89007-1-jjcao20@fudan.edu.cn> From: Martin Blumenstingl Date: Thu, 1 Jul 2021 23:34:37 +0200 Message-ID: Subject: Re: [PATCH v2] drm/meson: fix potential NULL pointer exception in meson_drv_unbind() To: Jiajun Cao Content-Type: text/plain; charset="UTF-8" X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Xin Tan , Neil Armstrong , David Airlie , Kevin Hilman , yuanxzhang@fudan.edu.cn, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Jerome Brunet Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hello, first of all: thanks for your patch and sorry for being late with my review question. On Fri, Jun 18, 2021 at 7:28 AM Jiajun Cao wrote: > > Fix a potential NULL pointer exception when meson_drv_unbind() > attempts to operate on the driver_data priv which may be NULL. > Add a null pointer check on the priv struct to avoid the NULL > pointer dereference after calling dev_get_drvdata(), just like > the null pointer checks done on the struct priv in the function > meson_drv_shutdown(), meson_drv_pm_suspend() and meson_drv_pm_resume(). I am trying to review Amlogic Meson related patches in the DRM subsystem so I can help Neil with this. However, I am still new to this so please help me educate on this topic. [...] > static void meson_drv_unbind(struct device *dev) > { > struct meson_drm *priv = dev_get_drvdata(dev); > - struct drm_device *drm = priv->drm; > + struct drm_device *drm; > + > + if (!priv) > + return; My understanding of the component framework is that meson_drv_unbind() is only called if previously meson_drv_bind() was called (and did not return any error). This is different from meson_drv_shutdown() (for example) because that can be called if meson_drv_probe() returns 0 (success) in case the "count" variable was 0 (then the probe function does nothing). As I mentioned before: I am still learning about the DRM subsystem in the Linux kernel. So it would be great if you could help me understand for which scenarios this newly added if-condition is needed. Thank you! Best regards, Martin 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=-0.7 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 4C449C11F67 for ; Thu, 1 Jul 2021 21:35:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 10276613DC for ; Thu, 1 Jul 2021 21:35:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 10276613DC Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=z0Pyd1QMfYp8FOKJulZEKxMNDbvworfSZbD/8wc5Bn8=; b=JulE004HFgZgAH coKKZT6pLw4OcomqXXmwNnSI+HGcZf81a1mCB6hrfsJtR6bjj/qAjAFzVRKf2yBYyHjCr1BCxO6FU gRaTEZTkaVrKUBUmL1eoykonDTixvCecqelQq51sBa4JklDzd/y/OYfZQNLDEqoTLC2zs35EUl+B2 8AiB5MKMz1bqsnE4JUJ88o3nHKF3p+3XXlWn44nVLgKIAY6g5CVDw6nO5FbW4xtdPDsv6KphOgOQM 19BPWI1MihyrGMscxYoYliQkjTog4N+AOeyhqjtVl41msOByS0awk4/M+y8qDrnLDF6fgbraqnDZR qyxCsgG6Yp1oNVEYmbdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lz4Kj-001DQC-11; Thu, 01 Jul 2021 21:34:53 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lz4Kf-001DOU-S1; Thu, 01 Jul 2021 21:34:51 +0000 Received: by mail-ej1-x633.google.com with SMTP id o5so12807066ejy.7; Thu, 01 Jul 2021 14:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MPm2mNfDFAFz6LZYHsop45CBgdHBv6hIIQ/VkHD6NKA=; b=HvTjCzluEHCx88k64sQ1uGioAhhF0RaQdU2TKB3xXaeeJ5jaQe1vkBMflOMt0RMTxj iUISIublp8cNy2n9ZdkE02AYBeYCS1djQFxZvV2JGCHLdd66U9E93k7aFXQjQqUha4P3 gRpV2RfUVWOWwQM5VAi6Iu2tuUxgsZtntXjHLJShIQOabUWw5/yhZM1Hznq5fkfwfPTZ d4U5x2mx1wgy1/l9DweE/vR+RveLBfEcovXEnJY8gbgzymFvtwmSmPVP3Rez8GQQcZeO PrNXkGm5v0mrRayTQyy39K48MnsXAF9RU2041qhATMIe45TwPkFjClaj2ONRwj87cH9L cDgw== 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=MPm2mNfDFAFz6LZYHsop45CBgdHBv6hIIQ/VkHD6NKA=; b=eQDg/LzZoIvxkAWgoJJwuB17+0eY0vz9duycvjFaM0tsWjdJs6rIMJ5y2zGjf4jkRg gxqh22w4WyeTfiRR0ff9lmpq0+9tfz9ZYUEiquFUVTG9mGNKbPoAV9YoGqQiwCR6+52N b+fUFpGNznEQGbU1hP33wKgWxrPdkApdc8NUVMMenkAwUO8/7QEfSAv+55ca+3sF8UMi CTWgq5dymj3MDY4BbN4jxnrs9CkSPXkYSHjFnp5VPRhB+D57NLfeli8PKrL7cC7As4yk 5JDrUgwpKc1Alt3pJfX9SJXzB9ER5WG9QyoL9qxYFLRg0+QyBQCzUgGtG3Jb9jU69zp8 zTIA== X-Gm-Message-State: AOAM530HXUBoE3GtXiL12ir4/TkrB/bwZjWVUDWu9u3uX7XMjLtev3Jk IgI7C0WZY6BYVdP1cQrT0XU8Jc7+g2iL0M1SFAA= X-Google-Smtp-Source: ABdhPJyZ3ThStcILU2DEuZlK8i1r5iDZm7d/h/AfGai6wlTFHJI9KAhQtrkXuxM3Ic6DSOSfkN1YPmywHBMsDeqD97Y= X-Received: by 2002:a17:906:36d5:: with SMTP id b21mr2013027ejc.258.1625175287929; Thu, 01 Jul 2021 14:34:47 -0700 (PDT) MIME-Version: 1.0 References: <20210618052800.89007-1-jjcao20@fudan.edu.cn> In-Reply-To: <20210618052800.89007-1-jjcao20@fudan.edu.cn> From: Martin Blumenstingl Date: Thu, 1 Jul 2021 23:34:37 +0200 Message-ID: Subject: Re: [PATCH v2] drm/meson: fix potential NULL pointer exception in meson_drv_unbind() To: Jiajun Cao Cc: yuanxzhang@fudan.edu.cn, Xin Tan , Neil Armstrong , David Airlie , Daniel Vetter , Kevin Hilman , Jerome Brunet , dri-devel@lists.freedesktop.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210701_143449_970418_CE2E7426 X-CRM114-Status: GOOD ( 19.07 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Hello, first of all: thanks for your patch and sorry for being late with my review question. On Fri, Jun 18, 2021 at 7:28 AM Jiajun Cao wrote: > > Fix a potential NULL pointer exception when meson_drv_unbind() > attempts to operate on the driver_data priv which may be NULL. > Add a null pointer check on the priv struct to avoid the NULL > pointer dereference after calling dev_get_drvdata(), just like > the null pointer checks done on the struct priv in the function > meson_drv_shutdown(), meson_drv_pm_suspend() and meson_drv_pm_resume(). I am trying to review Amlogic Meson related patches in the DRM subsystem so I can help Neil with this. However, I am still new to this so please help me educate on this topic. [...] > static void meson_drv_unbind(struct device *dev) > { > struct meson_drm *priv = dev_get_drvdata(dev); > - struct drm_device *drm = priv->drm; > + struct drm_device *drm; > + > + if (!priv) > + return; My understanding of the component framework is that meson_drv_unbind() is only called if previously meson_drv_bind() was called (and did not return any error). This is different from meson_drv_shutdown() (for example) because that can be called if meson_drv_probe() returns 0 (success) in case the "count" variable was 0 (then the probe function does nothing). As I mentioned before: I am still learning about the DRM subsystem in the Linux kernel. So it would be great if you could help me understand for which scenarios this newly added if-condition is needed. Thank you! Best regards, Martin _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic