@@ -162,8 +162,6 @@ static int cxl_port_perf_data_calculate(struct cxl_port *port,
162162 struct xarray * dsmas_xa )
163163{
164164 struct access_coordinate c ;
165- struct cxl_port * root_port ;
166- struct cxl_root * cxl_root ;
167165 struct dsmas_entry * dent ;
168166 int valid_entries = 0 ;
169167 unsigned long index ;
@@ -175,8 +173,11 @@ static int cxl_port_perf_data_calculate(struct cxl_port *port,
175173 return rc ;
176174 }
177175
178- root_port = find_cxl_root (port );
179- cxl_root = to_cxl_root (root_port );
176+ struct cxl_root * cxl_root __free (put_cxl_root ) = find_cxl_root (port );
177+
178+ if (!cxl_root )
179+ return - ENODEV ;
180+
180181 if (!cxl_root -> ops || !cxl_root -> ops -> qos_class )
181182 return - EOPNOTSUPP ;
182183
@@ -193,7 +194,8 @@ static int cxl_port_perf_data_calculate(struct cxl_port *port,
193194 dent -> coord .write_bandwidth );
194195
195196 dent -> entries = 1 ;
196- rc = cxl_root -> ops -> qos_class (root_port , & dent -> coord , 1 , & qos_class );
197+ rc = cxl_root -> ops -> qos_class (cxl_root , & dent -> coord , 1 ,
198+ & qos_class );
197199 if (rc != 1 )
198200 continue ;
199201
@@ -349,15 +351,19 @@ static int cxl_qos_class_verify(struct cxl_memdev *cxlmd)
349351{
350352 struct cxl_dev_state * cxlds = cxlmd -> cxlds ;
351353 struct cxl_memdev_state * mds = to_cxl_memdev_state (cxlds );
352- struct cxl_port * root_port __free (put_device ) = NULL ;
353354 LIST_HEAD (__discard );
354355 struct list_head * discard __free (dpa_perf ) = & __discard ;
356+ struct cxl_port * root_port ;
355357 int rc ;
356358
357- root_port = find_cxl_root (cxlmd -> endpoint );
358- if (!root_port )
359+ struct cxl_root * cxl_root __free (put_cxl_root ) =
360+ find_cxl_root (cxlmd -> endpoint );
361+
362+ if (!cxl_root )
359363 return - ENODEV ;
360364
365+ root_port = & cxl_root -> port ;
366+
361367 /* Check that the QTG IDs are all sane between end device and root decoders */
362368 cxl_qos_match (root_port , & mds -> ram_perf_list , discard );
363369 cxl_qos_match (root_port , & mds -> pmem_perf_list , discard );
0 commit comments