* [PATCH] cxl/fwctl: Cleanup unused fwctl_dev from cxl_features_state
@ 2025-03-07 22:11 Dan Williams
2025-03-07 22:26 ` Dave Jiang
0 siblings, 1 reply; 3+ messages in thread
From: Dan Williams @ 2025-03-07 22:11 UTC (permalink / raw)
To: linux-cxl; +Cc: Dave Jiang, Li Ming, Jonathan Cameron, Jason Gunthorpe
A review of devm_cxl_setup_fwctl() indicates a potential a use after
free condition for the ->fwctl_dev pointer given it is not cleared after
devm_add_action_or_reset() might have released it. However, nothing uses
it, so just delete it.
If it ever comes back it should be returned by devm_cxl_setup_fwctl() so
that users can always assume the pointer is either valid or NULL.
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Li Ming <ming.li@zohomail.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
base-commit: da0dd17604d4c70080497091c762a790b0871eff
drivers/cxl/core/features.c | 2 --
include/cxl/features.h | 2 --
2 files changed, 4 deletions(-)
diff --git a/drivers/cxl/core/features.c b/drivers/cxl/core/features.c
index caf92e9cea21..f4daefe3180e 100644
--- a/drivers/cxl/core/features.c
+++ b/drivers/cxl/core/features.c
@@ -700,8 +700,6 @@ int devm_cxl_setup_fwctl(struct cxl_memdev *cxlmd)
if (rc)
return rc;
- cxlfs->fwctl_dev = fwctl_dev;
-
return devm_add_action_or_reset(&cxlmd->dev, free_memdev_fwctl,
no_free_ptr(fwctl_dev));
}
diff --git a/include/cxl/features.h b/include/cxl/features.h
index ead63573b0b4..fbfdc601bd85 100644
--- a/include/cxl/features.h
+++ b/include/cxl/features.h
@@ -53,7 +53,6 @@ enum cxl_features_capability {
* @entries: CXl feature entry context
* @num_features: total Features supported by the device
* @ent: Flex array of Feature detail entries from the device
- * @fwctl_dev: Firmware Control device
*/
struct cxl_features_state {
struct cxl_dev_state *cxlds;
@@ -62,7 +61,6 @@ struct cxl_features_state {
int num_user_features;
struct cxl_feat_entry ent[] __counted_by(num_features);
} *entries;
- struct fwctl_device *fwctl_dev;
};
struct cxl_mailbox;
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] cxl/fwctl: Cleanup unused fwctl_dev from cxl_features_state
2025-03-07 22:11 [PATCH] cxl/fwctl: Cleanup unused fwctl_dev from cxl_features_state Dan Williams
@ 2025-03-07 22:26 ` Dave Jiang
2025-03-07 23:10 ` Jason Gunthorpe
0 siblings, 1 reply; 3+ messages in thread
From: Dave Jiang @ 2025-03-07 22:26 UTC (permalink / raw)
To: Dan Williams, linux-cxl; +Cc: Li Ming, Jonathan Cameron, Jason Gunthorpe
On 3/7/25 3:11 PM, Dan Williams wrote:
> A review of devm_cxl_setup_fwctl() indicates a potential a use after
> free condition for the ->fwctl_dev pointer given it is not cleared after
> devm_add_action_or_reset() might have released it. However, nothing uses
> it, so just delete it.
>
> If it ever comes back it should be returned by devm_cxl_setup_fwctl() so
> that users can always assume the pointer is either valid or NULL.
>
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Li Ming <ming.li@zohomail.com>
> Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
>
> base-commit: da0dd17604d4c70080497091c762a790b0871eff
>
> drivers/cxl/core/features.c | 2 --
> include/cxl/features.h | 2 --
> 2 files changed, 4 deletions(-)
>
> diff --git a/drivers/cxl/core/features.c b/drivers/cxl/core/features.c
> index caf92e9cea21..f4daefe3180e 100644
> --- a/drivers/cxl/core/features.c
> +++ b/drivers/cxl/core/features.c
> @@ -700,8 +700,6 @@ int devm_cxl_setup_fwctl(struct cxl_memdev *cxlmd)
> if (rc)
> return rc;
>
> - cxlfs->fwctl_dev = fwctl_dev;
> -
> return devm_add_action_or_reset(&cxlmd->dev, free_memdev_fwctl,
> no_free_ptr(fwctl_dev));
> }
> diff --git a/include/cxl/features.h b/include/cxl/features.h
> index ead63573b0b4..fbfdc601bd85 100644
> --- a/include/cxl/features.h
> +++ b/include/cxl/features.h
> @@ -53,7 +53,6 @@ enum cxl_features_capability {
> * @entries: CXl feature entry context
> * @num_features: total Features supported by the device
> * @ent: Flex array of Feature detail entries from the device
> - * @fwctl_dev: Firmware Control device
> */
> struct cxl_features_state {
> struct cxl_dev_state *cxlds;
> @@ -62,7 +61,6 @@ struct cxl_features_state {
> int num_user_features;
> struct cxl_feat_entry ent[] __counted_by(num_features);
> } *entries;
> - struct fwctl_device *fwctl_dev;
> };
>
> struct cxl_mailbox;
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] cxl/fwctl: Cleanup unused fwctl_dev from cxl_features_state
2025-03-07 22:26 ` Dave Jiang
@ 2025-03-07 23:10 ` Jason Gunthorpe
0 siblings, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2025-03-07 23:10 UTC (permalink / raw)
To: Dave Jiang; +Cc: Dan Williams, linux-cxl, Li Ming, Jonathan Cameron
On Fri, Mar 07, 2025 at 03:26:02PM -0700, Dave Jiang wrote:
>
>
> On 3/7/25 3:11 PM, Dan Williams wrote:
> > A review of devm_cxl_setup_fwctl() indicates a potential a use after
> > free condition for the ->fwctl_dev pointer given it is not cleared after
> > devm_add_action_or_reset() might have released it. However, nothing uses
> > it, so just delete it.
> >
> > If it ever comes back it should be returned by devm_cxl_setup_fwctl() so
> > that users can always assume the pointer is either valid or NULL.
> >
> > Cc: Dave Jiang <dave.jiang@intel.com>
> > Cc: Li Ming <ming.li@zohomail.com>
> > Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Jason Gunthorpe <jgg@nvidia.com>
> > Signed-off-by: Dan Williams <dan.j.williams@intel.com>
>
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
I can squash this into the v8
Thanks,
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-07 23:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-07 22:11 [PATCH] cxl/fwctl: Cleanup unused fwctl_dev from cxl_features_state Dan Williams
2025-03-07 22:26 ` Dave Jiang
2025-03-07 23:10 ` Jason Gunthorpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox