2024-01-19 13:28:37

by Ian Abbott

[permalink] [raw]
Subject: [PATCH 0/2] misc: hpilo: fix inconsistent device numbers

There is a logical bug in the use of device numbers in the hpilo driver.
The bug does not actually occur because the maximum number of supported
iLO devices is currently fixed at 1. Therefore, it's probably not worth
fixing in the "stable" kernel series.

Patch 1 fixes the bug. Patch 2 just renames a variable for clarity.

1) misc: hpilo: fix inconsistent device numbers
2) misc: hpilo: rename device creation loop variable

drivers/misc/hpilo.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)


2024-01-19 13:28:40

by Ian Abbott

[permalink] [raw]
Subject: [PATCH 1/2] misc: hpilo: fix inconsistent device numbers

Each iLO device is allocated `max_ccb` minor device numbers (one for
each channel). When `ilo_probe()` calls `device_create()` in a loop,
the minor device numbers passed to `device_create()` start at 0. For
consistency with the call to `cdev_add()`, and for consistency with the
calls to `device_destroy()` from `ilo_remove()`, the minor device
numbers passed to `device_create()` should start at the value in the
variable `start`. Fix it.

This is a logical bug rather than an actual bug, because the number of
supported devices is `MAX_ILO_DEV` which is defined as `1`.

Fixes: 89bcb05d9bbf ("HP iLO driver")
Signed-off-by: Ian Abbott <[email protected]>
---
drivers/misc/hpilo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/hpilo.c b/drivers/misc/hpilo.c
index f1b74d3f8958..3428a0bd5550 100644
--- a/drivers/misc/hpilo.c
+++ b/drivers/misc/hpilo.c
@@ -842,7 +842,7 @@ static int ilo_probe(struct pci_dev *pdev,
for (minor = 0 ; minor < max_ccb; minor++) {
struct device *dev;
dev = device_create(&ilo_class, &pdev->dev,
- MKDEV(ilo_major, minor), NULL,
+ MKDEV(ilo_major, start + minor), NULL,
"hpilo!d%dccb%d", devnum, minor);
if (IS_ERR(dev))
dev_err(&pdev->dev, "Could not create files\n");
--
2.43.0


2024-01-19 13:57:03

by Ian Abbott

[permalink] [raw]
Subject: [PATCH 2/2] misc: hpilo: rename device creation loop variable

In `ilo_probe()`, the loop variable `minor` isn't really the minor
device number, it's the channel or slot number. Rename it to `slot` for
consistency.

Signed-off-by: Ian Abbott <[email protected]>
---
drivers/misc/hpilo.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/hpilo.c b/drivers/misc/hpilo.c
index 3428a0bd5550..04bd34c8c506 100644
--- a/drivers/misc/hpilo.c
+++ b/drivers/misc/hpilo.c
@@ -770,7 +770,7 @@ static void ilo_remove(struct pci_dev *pdev)
static int ilo_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
- int devnum, minor, start, error = 0;
+ int devnum, slot, start, error = 0;
struct ilo_hwinfo *ilo_hw;

if (pci_match_id(ilo_blacklist, pdev)) {
@@ -839,11 +839,11 @@ static int ilo_probe(struct pci_dev *pdev,
goto remove_isr;
}

- for (minor = 0 ; minor < max_ccb; minor++) {
+ for (slot = 0; slot < max_ccb; slot++) {
struct device *dev;
dev = device_create(&ilo_class, &pdev->dev,
- MKDEV(ilo_major, start + minor), NULL,
- "hpilo!d%dccb%d", devnum, minor);
+ MKDEV(ilo_major, start + slot), NULL,
+ "hpilo!d%dccb%d", devnum, slot);
if (IS_ERR(dev))
dev_err(&pdev->dev, "Could not create files\n");
}
--
2.43.0