mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Harry Wentland <harry.wentland@amd.com>
To: "Arnd Bergmann" <arnd@arndb.de>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>
Cc: David Airlie <airlied@linux.ie>,
	Horace Chen <horace.chen@amd.com>,
	linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org,
	Xiangliang Yu <Xiangliang.Yu@amd.com>,
	dri-devel@lists.freedesktop.org, Monk Liu <Monk.Liu@amd.com>
Subject: Re: [PATCH] drm/amdgpu/virt: don't dereference undefined 'module' struct
Date: Thu, 2 Nov 2017 15:22:05 -0400	[thread overview]
Message-ID: <afba5139-ec05-69a6-fe8f-b8b3d434f2d1@amd.com> (raw)
In-Reply-To: <20171102112619.72157-1-arnd@arndb.de>

On 2017-11-02 07:25 AM, Arnd Bergmann wrote:
> Accessing the THIS_MODULE directly is only possible when modules
> are enabled, otherwise we get a build failure:
> 
> drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c: In function 'amdgpu_virt_init_data_exchange':
> drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c:331:20: error: dereferencing pointer to incomplete type 'struct module'
> 
> Further, THIS_MODULE is NULL when the driver is built-in, so the
> code would likely cause a NULL pointer dereference.
> 
> This adds an #ifdef check to avoid the compile-time error, plus
> a NULL pointer check before dereferencing THIS_MODULE. It might
> be better to find a way to avoid using the module version
> altogether.
> 
> Fixes: 2dc8f81e4f82 ("drm/amdgpu: SR-IOV data exchange between PF&VF")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks like 'str' isn't even used here.

Either way, this change by itself is correct and
Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> index e97f80f86005..4e4a476593e8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> @@ -328,9 +328,11 @@ void amdgpu_virt_init_data_exchange(struct amdgpu_device *adev)
>  					sizeof(amdgim_vf2pf_info));
>  				AMDGPU_FW_VRAM_VF2PF_READ(adev, driver_version,
>  					&str);
> +#ifdef MODULE
>  				if (THIS_MODULE->version != NULL)
>  					strcpy(str, THIS_MODULE->version);
>  				else
> +#endif
>  					strcpy(str, "N/A");
>  				AMDGPU_FW_VRAM_VF2PF_WRITE(adev, driver_cert,
>  					0);
> 

  reply	other threads:[~2017-11-02 19:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-02 11:25 Arnd Bergmann
2017-11-02 19:22 ` Harry Wentland [this message]
2017-11-02 20:57   ` Alex Deucher
2017-11-03  6:57 ` Yu, Xiangliang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=afba5139-ec05-69a6-fe8f-b8b3d434f2d1@amd.com \
    --to=harry.wentland@amd.com \
    --cc=Monk.Liu@amd.com \
    --cc=Xiangliang.Yu@amd.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=arnd@arndb.de \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=horace.chen@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®