Skip to content

Commit cb925d3

Browse files
mwajdeczashutoshx
authored andcommitted
drm/xe/oa: Fix potential NPD when OA is not initialized
If oa->xe can be NULL then we shall not use it as a valid pointer. Fixes: cdf02fe ("drm/xe/oa/uapi: Add/remove OA config perf ops") Fixes: b6fd51c ("drm/xe/oa/uapi: Define and parse OA stream properties") Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: Ashutosh Dixit <ashutosh.dixit@intel.com> Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240619175427.861-1-michal.wajdeczko@intel.com
1 parent 7a89334 commit cb925d3

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

drivers/gpu/drm/xe/xe_oa.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,15 +1725,16 @@ static int xe_oa_user_extensions(struct xe_oa *oa, u64 extension, int ext_number
17251725
*/
17261726
int xe_oa_stream_open_ioctl(struct drm_device *dev, u64 data, struct drm_file *file)
17271727
{
1728-
struct xe_oa *oa = &to_xe_device(dev)->oa;
1728+
struct xe_device *xe = to_xe_device(dev);
1729+
struct xe_oa *oa = &xe->oa;
17291730
struct xe_file *xef = to_xe_file(file);
17301731
struct xe_oa_open_param param = {};
17311732
const struct xe_oa_format *f;
17321733
bool privileged_op = true;
17331734
int ret;
17341735

17351736
if (!oa->xe) {
1736-
drm_dbg(&oa->xe->drm, "xe oa interface not available for this system\n");
1737+
drm_dbg(&xe->drm, "xe oa interface not available for this system\n");
17371738
return -ENODEV;
17381739
}
17391740

@@ -2005,15 +2006,16 @@ static int create_dynamic_oa_sysfs_entry(struct xe_oa *oa,
20052006
*/
20062007
int xe_oa_add_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *file)
20072008
{
2008-
struct xe_oa *oa = &to_xe_device(dev)->oa;
2009+
struct xe_device *xe = to_xe_device(dev);
2010+
struct xe_oa *oa = &xe->oa;
20092011
struct drm_xe_oa_config param;
20102012
struct drm_xe_oa_config *arg = &param;
20112013
struct xe_oa_config *oa_config, *tmp;
20122014
struct xe_oa_reg *regs;
20132015
int err, id;
20142016

20152017
if (!oa->xe) {
2016-
drm_dbg(&oa->xe->drm, "xe oa interface not available for this system\n");
2018+
drm_dbg(&xe->drm, "xe oa interface not available for this system\n");
20172019
return -ENODEV;
20182020
}
20192021

@@ -2106,13 +2108,14 @@ int xe_oa_add_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *fi
21062108
*/
21072109
int xe_oa_remove_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *file)
21082110
{
2109-
struct xe_oa *oa = &to_xe_device(dev)->oa;
2111+
struct xe_device *xe = to_xe_device(dev);
2112+
struct xe_oa *oa = &xe->oa;
21102113
struct xe_oa_config *oa_config;
21112114
u64 arg, *ptr = u64_to_user_ptr(data);
21122115
int ret;
21132116

21142117
if (!oa->xe) {
2115-
drm_dbg(&oa->xe->drm, "xe oa interface not available for this system\n");
2118+
drm_dbg(&xe->drm, "xe oa interface not available for this system\n");
21162119
return -ENODEV;
21172120
}
21182121

0 commit comments

Comments
 (0)