Skip to contentSkip to conversation

cdx: Fix cdx_mmap_resource() after constifying attr in ->mmap()

PATCH In review Nathan Chancellor 4 participants 6 messages Nov 7, 2024 – Nov 11, 2024 AMD cdx bus driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cdx: Fix cdx_mmap_resource() after constifying attr in ->mmap()

Commit 94a20fb9af16 ("sysfs: treewide: constify attribute callback of bin_attribute::mmap()") missed updating the attr parameter of cdx_mmap_resource(), resulting in a build failure.

drivers/cdx/cdx.c: In function 'cdx_create_res_attr':
drivers/cdx/cdx.c:773:24: error: assignment to 'int (*)(struct file *, struct kobject *, const struct bin_attribute *, struct vm_area_struct *)' from incompatible pointer type 'int (*)(struct file *, struct kobject *, struct bin_attribute *, struct vm_area_struct *)' [-Wincompatible-pointer-types]

    773 |         res_attr->mmap = cdx_mmap_resource;
        |                        ^

Update cdx_mmap_resource() to match, resolving the build failure.

Fixes 94a20fb9af16 ("sysfs: treewide: constify attribute callback of bin_attribute::mmap()")
---
 drivers/cdx/cdx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cdx/cdx.c +1 -1
index 07371cb653d356977cbd3dd99a1b848146d5a993..316bd89a95caf97163a126478985c52b1b596bb4 100644
@@ -707,7 +707,7 @@ static const struct vm_operations_struct cdx_phys_vm_ops = {
  * Return: true on success, false otherwise.
  */
 static int cdx_mmap_resource(struct file *fp, struct kobject *kobj,
-			     struct bin_attribute *attr,
+			     const struct bin_attribute *attr,
 			     struct vm_area_struct *vma)
 {
 	struct cdx_device *cdx_dev = to_cdx_device(kobj_to_dev(kobj));

---
base-commit: 298c2af4788ed027a42c2bab0f210219825fb5fd
change-id: 20241107-sysfs-const-mmap-fix-cdx-1457914fe16d

Best regards,

Signature · 1 line
Nathan Chancellor <[email protected]>
Tested-by on v1 1/1
#1 lore raw
Quoted 6 lines · Nathan Chancellor

Commit 94a20fb9af16 ("sysfs: treewide: constify attribute callback of bin_attribute::mmap()") missed updating the attr parameter of cdx_mmap_resource(), resulting in a build failure.

drivers/cdx/cdx.c: In function 'cdx_create_res_attr':
drivers/cdx/cdx.c:773:24: error: assignment to 'int (*)(struct file *, struct kobject *, const struct bin_attribute *, struct vm_area_struct *)' from incompatible pointer type 'int (*)(struct file *, struct kobject *, struct bin_attribute *, struct vm_area_struct *)' [-Wincompatible-pointer-types]

Quoted 7 lines
    773 |         res_attr->mmap = cdx_mmap_resource;
        |                        ^

Update cdx_mmap_resource() to match, resolving the build failure.

Fixes 94a20fb9af16 ("sysfs: treewide: constify attribute callback of bin_attribute::mmap()")

Ran into the described problem for my daily -next builds on all Fedora releases on ARM64 yesterday and today. This fixes it for me.

Ciao, Thorsten

Reviewed-by Thomas Weißschuu on v1 1/1
#2 lore raw
In reply to Nathan Chancellor

Hi Nathan,

Nov 7, 2024 12:07:56 Nathan Chancellor <[email protected]>:

Quoted 4 lines

Commit 94a20fb9af16 ("sysfs: treewide: constify attribute callback of bin_attribute::mmap()") missed updating the attr parameter of cdx_mmap_resource(), resulting in a build failure.

Quoted 8 lines

  drivers/cdx/cdx.c: In function 'cdx_create_res_attr':
  drivers/cdx/cdx.c:773:24: error: assignment to 'int (*)(struct file *, struct kobject *, const struct bin_attribute *, struct vm_area_struct *)' from incompatible pointer type 'int (*)(struct file *, struct kobject *, struct bin_attribute *, struct vm_area_struct *)' [-Wincompatible-pointer-types] 773 |         res_attr->mmap = cdx_mmap_resource;
        |                        ^

Update cdx_mmap_resource() to match, resolving the build failure.

Fixes 94a20fb9af16 ("sysfs: treewide: constify attribute callback of bin_attribute::mmap()")

I'm not sure about the Fixes tag.
cdx.c is not yet in mainline and this change should be folded into the cdx patch or the sysfs patch, depending on their order in the merge window. I guess Greg will take care of it.

Thanks for the notification, though!

Quoted 1 line

If it ends up as a real commit:

Quoted 25 lines

---
drivers/cdx/cdx.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cdx/cdx.c +1 -2
index 07371cb653d356977cbd3dd99a1b848146d5a993..316bd89a95caf97163a126478985c52b1b596bb4 100644
@@ -707,7 +707,7 @@ static const struct vm_operations_struct cdx_phys_vm_ops = {
   * Return: true on success, false otherwise.
   */
 static int cdx_mmap_resource(struct file *fp, struct kobject *kobj,
-                struct bin_attribute *attr,
+                const struct bin_attribute *attr,
                  struct vm_area_struct *vma)
 {
     struct cdx_device *cdx_dev = to_cdx_device(kobj_to_dev(kobj));
 
---

base-commit: 298c2af4788ed027a42c2bab0f210219825fb5fd
change-id: 20241107-sysfs-const-mmap-fix-cdx-1457914fe16d

Best regards,
--
Nathan Chancellor <[email protected]>

#3 lore raw
Quoted 6 lines · Thomas Weißschuh

Nov 7, 2024 12:07:56 Nathan Chancellor <[email protected]>:

Quoted 1 line
Fixes 94a20fb9af16 ("sysfs: treewide: constify attribute callback of bin_attribute::mmap()")

I'm not sure about the Fixes tag.
cdx.c is not yet in mainline and this change should be folded into the cdx patch or the sysfs patch, depending on their order in the merge window. I guess Greg will take care of it.

This code is in mainline, so I think the Fixes tag is correct?

  $ git grep cdx_mmap_resource v6.12-rc1 drivers/cdx/cdx.c
  v6.12-rc1:drivers/cdx/cdx.c: * cdx_mmap_resource - map a CDX resource into user memory space
  v6.12-rc1:drivers/cdx/cdx.c:static int cdx_mmap_resource(struct file *fp, struct kobject *kobj,
  v6.12-rc1:drivers/cdx/cdx.c:        res_attr->mmap = cdx_mmap_resource;

The error is reproducible on driver-core-next since that is what I based this change on.

Thanks for the review!

Cheers,
Nathan

#4 lore raw

Nov 8, 2024 12:54:41 Nathan Chancellor <[email protected]>:

Quoted 9 lines · Thomas Weißschuh
Quoted 6 lines

Nov 7, 2024 12:07:56 Nathan Chancellor <[email protected]>:

Quoted 1 line
Fixes 94a20fb9af16 ("sysfs: treewide: constify attribute callback of bin_attribute::mmap()")

I'm not sure about the Fixes tag.
cdx.c is not yet in mainline and this change should be folded into the cdx patch or the sysfs patch, depending on their order in the merge window. I guess Greg will take care of it.

This code is in mainline, so I think the Fixes tag is correct?

Indeed. Sorry for the noise.
I re-checked this before writing the other mail, but somehow failed. (Maybe because I did it on a phone)

I'm wondering how this got through 0day, too.
Anyways, it shouldn't matter.
Thanks again for the fix!

Quoted 12 lines
  $ git grep cdx_mmap_resource v6.12-rc1 drivers/cdx/cdx.c
  v6.12-rc1:drivers/cdx/cdx.c: * cdx_mmap_resource - map a CDX resource into user memory space
  v6.12-rc1:drivers/cdx/cdx.c:static int cdx_mmap_resource(struct file *fp, struct kobject *kobj,
  v6.12-rc1:drivers/cdx/cdx.c:        res_attr->mmap = cdx_mmap_resource;

The error is reproducible on driver-core-next since that is what I based this change on.

Thanks for the review!

Cheers,
Nathan

maintainer Acked-by on v1 1/1
#5 lore raw
In reply to Nathan Chancellor
Quoted 11 lines

Commit 94a20fb9af16 ("sysfs: treewide: constify attribute callback of bin_attribute::mmap()") missed updating the attr parameter of cdx_mmap_resource(), resulting in a build failure.

drivers/cdx/cdx.c: In function 'cdx_create_res_attr':
drivers/cdx/cdx.c:773:24: error: assignment to 'int (*)(struct file *, struct kobject *,
const struct bin_attribute *, struct vm_area_struct *)' from incompatible pointer type 'int (*)(struct file *, struct kobject *, struct bin_attribute *, struct vm_area_struct *)' [- Wincompatible-pointer-types]

Quoted 8 lines
    773 |         res_attr->mmap = cdx_mmap_resource;
        |                        ^

Update cdx_mmap_resource() to match, resolving the build failure.

Fixes 94a20fb9af16 ("sysfs: treewide: constify attribute callback of

bin_attribute::mmap()")