Skip to contentSkip to conversation

EDAC/i10nm: Fix mdev reference leak in i10nm_get_ddr_munits()

PATCH Applied Wentao Liang 4 participants 12 messages Sep 16 – Sep 23

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 EDAC/i10nm: Fix mdev reference leak in i10nm_get_ddr_munits()

In i10nm_get_ddr_munits(), get_ddr_munit() returns a PCI device with its reference count incremented. If ioremap() fails to map the MMIO space of the memory controller, the function returns -ENODEV without putting the reference held by mdev, leaking it.

Put the device reference before returning on the ioremap failure path.

Fixes c545f5e41225 ("EDAC/i10nm: Skip the absent memory controllers")
---
 drivers/edac/i10nm_base.c | 1 +
 1 file changed, 1 insertion(+)
drivers/edac/i10nm_base.c +1 -0
index 63df35444214..b0cabe0daccd 100644
@@ -847,6 +847,7 @@ static int i10nm_get_ddr_munits(void)
 
 			mbase = ioremap(base + off, size);
 			if (!mbase) {
+				pci_dev_put(mdev);
 				i10nm_printk(KERN_ERR, "Failed to ioremap 0x%llx\n",
 					     base + off);
 				return -ENODEV;
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines

From: Wentao Liang <[email protected]>
Sent: Wednesday, September 16, 2026 5:13 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Wentao Liang <[email protected]>; [email protected]
Subject: [PATCH] EDAC/i10nm: Fix mdev reference leak in i10nm_get_ddr_munits()

External email: Use caution opening links or attachments

In i10nm_get_ddr_munits(), get_ddr_munit() returns a PCI device with its reference count incremented. If ioremap() fails to map the MMIO space of the memory controller, the function returns -ENODEV without putting the reference held by mdev, leaking it.

Quoted 5 lines

Put the device reference before returning on the ioremap failure path.

Fixes c545f5e41225 ("EDAC/i10nm: Skip the absent memory controllers")

LGTM,

[...]

maintainer Applied
#2 lore raw
In reply to Wentao Liang
Quoted 6 lines · Wentao Liang

In i10nm_get_ddr_munits(), get_ddr_munit() returns a PCI device with its reference count incremented. If ioremap() fails to map the MMIO space of the memory controller, the function returns -ENODEV without putting the reference held by mdev, leaking it.

Put the device reference before returning on the ioremap failure path.

Applied. Thanks.

-Tony

maintainer
#3 lore raw

Hi Tony,

Quoted 9 lines · Tony
Quoted 6 lines · Wentao Liang

In i10nm_get_ddr_munits(), get_ddr_munit() returns a PCI device with its reference count incremented. If ioremap() fails to map the MMIO space of the memory controller, the function returns -ENODEV without putting the reference held by mdev, leaking it.

Put the device reference before returning on the ioremap failure path.

Applied. Thanks.

this one has CC:stable. That means it needs to go to Linus now. If so, it needs to be into edac-urgent.

Yes? No?

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#4 lore raw
Quoted 9 lines · Borislav Petkov

Hi Tony,

Quoted 6 lines · Tony
Quoted 5 lines · Wentao Liang

In i10nm_get_ddr_munits(), get_ddr_munit() returns a PCI device with its reference count incremented. If ioremap() fails to map the MMIO space of the memory controller, the function returns -ENODEV without putting the reference held by mdev, leaking it.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Put the device reference before returning on the ioremap failure path.

Applied. Thanks.

this one has CC:stable. That means it needs to go to Linus now. If so, it needs to be into edac-urgent.

I though urgent was for:
1) Fixing something that broke in the current merge window
2) Fixing something that's really important (security, corruption)

This is just an old issue that's been around for ages.

Quoted 2 lines

Yes? No?

No.

-Tony

maintainer
#5 lore raw

Dropping stable@ from CC as it shouldn't be on CC.

Quoted 5 lines · Tony

I though urgent was for:
1) Fixing something that broke in the current merge window
2) Fixing something that's really important (security, corruption)

This is just an old issue that's been around for ages.

If this patch has CC:stable and a Fixes: tag, then it'll get backported to stable. So does it matter when it gets sent to Linus?

IOW, those two things do turn it into an urgent patch.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#6 lore raw
Quoted 7 lines · Borislav Petkov

Dropping stable@ from CC as it shouldn't be on CC.

Quoted 4 lines · Tony

I though urgent was for:
1) Fixing something that broke in the current merge window
2) Fixing something that's really important (security, corruption)

Quoted 6 lines
Quoted 1 line

This is just an old issue that's been around for ages.

If this patch has CC:stable and a Fixes: tag, then it'll get backported to stable. So does it matter when it gets sent to Linus?

IOW, those two things do turn it into an urgent patch.

The "Fixes:" tag is a matter of fact. The "Cc: stable" is just an opinion.

An extreme example would be a patch that fixes a spelling error in a comment posted on a Friday before Linus is expected to tag a "final" release in a cycle. A "Cc: stable" on that patch shouldn't trigger sending to Linus via an urgent pull.

But if you want to add this patch to edac-urgent, then go ahead.

-Tony

maintainer
#7 lore raw
Quoted 2 lines · Tony

The "Fixes:" tag is a matter of fact. The "Cc: stable" is just an opinion.

Are you being serious here?

"CC: stable" is a matter of opinion?!?!

Tony, where are you getting this from? Please point me to the docs where we state that, please, because I have never read it before.

Maybe I have missed that memo, who knows?

All I know is that stable folks appreciate and more or less rely on CC:stable from the patch committers so that they can know to pick up the patch quick. So CC:stable is actually a statement: this patch should go to stable.

Fixes is just a tag that shows which commit it fixes.
Quoted 3 lines

An extreme example would be a patch that fixes a spelling error in a comment posted on a Friday before Linus is expected to tag a "final" release in a cycle. A "Cc: stable" on that patch shouldn't trigger

A patch like that should *NEVER* get CC:stable.

Quoted 1 line

But if you want to add this patch to edac-urgent, then go ahead.

I want us to agree on the nomenclature so that there are no misunderstandings.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#8 lore raw
Quoted 10 lines · Borislav Petkov
Quoted 2 lines · Tony

The "Fixes:" tag is a matter of fact. The "Cc: stable" is just an opinion.

Are you being serious here?

"CC: stable" is a matter of opinion?!?!

Tony, where are you getting this from? Please point me to the docs where we state that, please, because I have never read it before.

In Documentation/process/howto.rst

- After two weeks a -rc1 kernel is released and the focus is on making the new kernel as rock solid as possible. Most of the patches at this point should fix a regression. Bugs that have always existed are not regressions, so only push these kinds of fixes if they are important.

and Documentation/process/2.Process.rst

The merge window lasts for approximately two weeks. At the end of this time, Linus Torvalds will declare that the window is closed and release the first of the "rc" kernels. For the kernel which is destined to be 9.x, for example, the release which happens at the end of the merge window will be called 9.x-rc1. The -rc1 release is the signal that the time to merge new features has passed, and that the time to stabilize the next kernel has begun.

and Documentation/process/stable-kernel-rules.rst says when to add Cc: stable

- It fixes a problem like an oops, a hang, data corruption, a real security issue, a hardware quirk, a build error (but not for things marked CONFIG_BROKEN), or some "oh, that's not good" issue.

Quoted 7 lines

Maybe I have missed that memo, who knows?

All I know is that stable folks appreciate and more or less rely on CC:stable from the patch committers so that they can know to pick up the patch quick. So CC:stable is actually a statement: this patch should go to stable.

Quoted 7 lines
Fixes is just a tag that shows which commit it fixes.
Quoted 3 lines

An extreme example would be a patch that fixes a spelling error in a comment posted on a Friday before Linus is expected to tag a "final" release in a cycle. A "Cc: stable" on that patch shouldn't trigger

A patch like that should *NEVER* get CC:stable.

The above is a clear example that should not be tagged for stable. I'm suggesting that this EDAC bug doesn't meet the stable criteria.

I ought to have quizzed the submitter on why they thought it needed the tag.

Quoted 4 lines
Quoted 2 lines

But if you want to add this patch to edac-urgent, then go ahead.

I want us to agree on the nomenclature so that there are no misunderstandings.

-Tony

maintainer
#9 lore raw
Quoted 2 lines · Tony

The above is a clear example that should not be tagged for stable. I'm suggesting that this EDAC bug doesn't meet the stable criteria.

Aaaha, I see it now. You basically want to point out that this patch shouldnt've been tagged for stable in the first place.

And I agree - old, error handling path, patch is probably AI-caused, and nothing really someone hits.

Quoted 2 lines

I ought to have quizzed the submitter on why they thought it needed the tag.

Actually, that is your job. And you should remove it if you don't think the patch is stable material. Because the stable tag causes a *lot* of work downstream in distros and stable kernels picking up this patch and trying to figure out why is it even stable material, what it is fixing, should their customers upgrade, yadda yadda.

So, what I would do is, rebase the branch and zap the stable tag. The stable tag is not something we should use willy-nilly but think twice whether we really want to pile more work for distros and stable folks.

And if submitters cannot give a good reason why stable, then off it goes.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#10 lore raw
Quoted 3 lines

So, what I would do is, rebase the branch and zap the stable tag. The stable tag is not something we should use willy-nilly but think twice whether we really want to pile more work for distros and stable folks.

Tag zapped. Updated edac-drivers branch force-pushed and merged into edac-for-next (replacing old merge).

-Tony

maintainer
#11 lore raw
Quoted 6 lines · Tony
Quoted 3 lines

So, what I would do is, rebase the branch and zap the stable tag. The stable tag is not something we should use willy-nilly but think twice whether we really want to pile more work for distros and stable folks.

Tag zapped. Updated edac-drivers branch force-pushed and merged into edac-for-next (replacing old merge).

Thanks!

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette