diff mbox series

drm/i915/dmc: Add dmc null check

Message ID 20241009065434.1799459-2-suraj.kandpal@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/dmc: Add dmc null check | expand

Commit Message

Kandpal, Suraj Oct. 9, 2024, 6:54 a.m. UTC
Add dmc null check before dereferncing to get the major and minor
version.

Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
---
 drivers/gpu/drm/i915/display/intel_dmc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Jani Nikula Oct. 9, 2024, 9:31 a.m. UTC | #1
On Wed, 09 Oct 2024, Suraj Kandpal <suraj.kandpal@intel.com> wrote:
> Add dmc null check before dereferncing to get the major and minor
> version.
>
> Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_dmc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_dmc.c b/drivers/gpu/drm/i915/display/intel_dmc.c
> index 48bbbf8f312c..8c193de0e253 100644
> --- a/drivers/gpu/drm/i915/display/intel_dmc.c
> +++ b/drivers/gpu/drm/i915/display/intel_dmc.c
> @@ -1263,8 +1263,9 @@ static int intel_dmc_debugfs_status_show(struct seq_file *m, void *unused)
>  	if (!intel_dmc_has_payload(display))

See what this does.

BR,
Jani.

>  		goto out;
>  
> -	seq_printf(m, "version: %d.%d\n", DMC_VERSION_MAJOR(dmc->version),
> -		   DMC_VERSION_MINOR(dmc->version));
> +	if (dmc)
> +		seq_printf(m, "version: %d.%d\n", DMC_VERSION_MAJOR(dmc->version),
> +			   DMC_VERSION_MINOR(dmc->version));
>  
>  	if (DISPLAY_VER(display) >= 12) {
>  		i915_reg_t dc3co_reg;
Kandpal, Suraj Oct. 9, 2024, 10:47 a.m. UTC | #2
> -----Original Message-----
> From: Jani Nikula <jani.nikula@linux.intel.com>
> Sent: Wednesday, October 9, 2024 3:01 PM
> To: Kandpal, Suraj <suraj.kandpal@intel.com>; intel-
> xe@lists.freedesktop.org; intel-gfx@lists.freedesktop.org
> Cc: Shankar, Uma <uma.shankar@intel.com>; Borah, Chaitanya Kumar
> <chaitanya.kumar.borah@intel.com>; Kandpal, Suraj
> <suraj.kandpal@intel.com>
> Subject: Re: [PATCH] drm/i915/dmc: Add dmc null check
> 
> On Wed, 09 Oct 2024, Suraj Kandpal <suraj.kandpal@intel.com> wrote:
> > Add dmc null check before dereferncing to get the major and minor
> > version.
> >
> > Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
> > ---
> >  drivers/gpu/drm/i915/display/intel_dmc.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/display/intel_dmc.c
> > b/drivers/gpu/drm/i915/display/intel_dmc.c
> > index 48bbbf8f312c..8c193de0e253 100644
> > --- a/drivers/gpu/drm/i915/display/intel_dmc.c
> > +++ b/drivers/gpu/drm/i915/display/intel_dmc.c
> > @@ -1263,8 +1263,9 @@ static int intel_dmc_debugfs_status_show(struct
> seq_file *m, void *unused)
> >  	if (!intel_dmc_has_payload(display))
> 
> See what this does.

Ahh ohkay got it.


> 
> BR,
> Jani.
> 
> >  		goto out;
> >
> > -	seq_printf(m, "version: %d.%d\n", DMC_VERSION_MAJOR(dmc-
> >version),
> > -		   DMC_VERSION_MINOR(dmc->version));
> > +	if (dmc)
> > +		seq_printf(m, "version: %d.%d\n",
> DMC_VERSION_MAJOR(dmc->version),
> > +			   DMC_VERSION_MINOR(dmc->version));
> >
> >  	if (DISPLAY_VER(display) >= 12) {
> >  		i915_reg_t dc3co_reg;
> 
> --
> Jani Nikula, Intel
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_dmc.c b/drivers/gpu/drm/i915/display/intel_dmc.c
index 48bbbf8f312c..8c193de0e253 100644
--- a/drivers/gpu/drm/i915/display/intel_dmc.c
+++ b/drivers/gpu/drm/i915/display/intel_dmc.c
@@ -1263,8 +1263,9 @@  static int intel_dmc_debugfs_status_show(struct seq_file *m, void *unused)
 	if (!intel_dmc_has_payload(display))
 		goto out;
 
-	seq_printf(m, "version: %d.%d\n", DMC_VERSION_MAJOR(dmc->version),
-		   DMC_VERSION_MINOR(dmc->version));
+	if (dmc)
+		seq_printf(m, "version: %d.%d\n", DMC_VERSION_MAJOR(dmc->version),
+			   DMC_VERSION_MINOR(dmc->version));
 
 	if (DISPLAY_VER(display) >= 12) {
 		i915_reg_t dc3co_reg;