From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Ira Weiny <ira.weiny@intel.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
Dave Jiang <dave.jiang@intel.com>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
<linux-cxl@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Ben Widawsky <bwidawsk@kernel.org>
Subject: Re: [PATCH] cxl/region: Clarify pointers in unregister_region()
Date: Wed, 30 Aug 2023 12:06:01 +0100 [thread overview]
Message-ID: <20230830120601.000043a6@Huawei.com> (raw)
In-Reply-To: <20230829-cxl-clarify-ptrs-v1-1-40e0705c6188@intel.com>
On Tue, 29 Aug 2023 14:47:46 -0700
Ira Weiny <ira.weiny@intel.com> wrote:
> devm_add_action_or_reset() passes a void * data parameter to the
> callback. In the case of CXL regions, unregister_region() is passed a
> struct cxl_region *.
>
> unregister_region() incorrectly interprets this as a struct device
> pointer. Fortunately the device structure was the first member of
> cxl_region. Therefore the code still works. However, should struct
> cxl_region change the bug could be subtle.
>
> Use the proper types in unregister_region() and extract the device
> pointer correctly.
>
> Fixes: 779dd20cfb56 ("cxl/region: Add region creation support")
> Cc: Ben Widawsky <bwidawsk@kernel.org>
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> drivers/cxl/core/region.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index e115ba382e04..471d305ef675 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -2018,10 +2018,11 @@ static struct cxl_region *to_cxl_region(struct device *dev)
> return container_of(dev, struct cxl_region, dev);
> }
>
> -static void unregister_region(void *dev)
> +static void unregister_region(void *_cxlr)
> {
> - struct cxl_region *cxlr = to_cxl_region(dev);
> + struct cxl_region *cxlr = _cxlr;
> struct cxl_region_params *p = &cxlr->params;
> + struct device *dev = &cxlr->dev;
> int i;
>
> device_del(dev);
>
> ---
> base-commit: 1c59d383390f970b891b503b7f79b63a02db2ec5
> change-id: 20230829-cxl-clarify-ptrs-f38255b7e52b
>
> Best regards,
next prev parent reply other threads:[~2023-08-30 18:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-29 21:47 [PATCH] cxl/region: Clarify pointers in unregister_region() Ira Weiny
2023-08-30 11:06 ` Jonathan Cameron [this message]
2023-08-30 15:48 ` Davidlohr Bueso
2023-08-30 17:36 ` Dave Jiang
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=20230830120601.000043a6@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=bwidawsk@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vishal.l.verma@intel.com \
/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