* [PATCH] sh: dma-sysfs: add missing put_device() in dma_create_sysfs_files()
@ 2025-12-20 6:28 Haoxiang Li
2025-12-20 13:56 ` Markus Elfring
0 siblings, 1 reply; 3+ messages in thread
From: Haoxiang Li @ 2025-12-20 6:28 UTC (permalink / raw)
To: ysato, dalias, glaubitz, kay.sievers, gregkh
Cc: linux-sh, linux-kernel, Haoxiang Li, stable
If device_register() fails, call put_device() to drop the device
reference. Also, call device_unregister() if device_create_file()
fails.
Found by code review.
Fixes: dc6876a288cc ("sh: dma - convert sysdev_class to a regular subsystem")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
arch/sh/drivers/dma/dma-sysfs.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/sh/drivers/dma/dma-sysfs.c b/arch/sh/drivers/dma/dma-sysfs.c
index 9f666280d80c..5695fd0a0cd7 100644
--- a/arch/sh/drivers/dma/dma-sysfs.c
+++ b/arch/sh/drivers/dma/dma-sysfs.c
@@ -134,8 +134,10 @@ int dma_create_sysfs_files(struct dma_channel *chan, struct dma_info *info)
dev->bus = &dma_subsys;
ret = device_register(dev);
- if (ret)
+ if (ret) {
+ put_device(dev);
return ret;
+ }
ret |= device_create_file(dev, &dev_attr_dev_id);
ret |= device_create_file(dev, &dev_attr_count);
@@ -145,6 +147,7 @@ int dma_create_sysfs_files(struct dma_channel *chan, struct dma_info *info)
if (unlikely(ret)) {
dev_err(&info->pdev->dev, "Failed creating attrs\n");
+ device_unregister(dev);
return ret;
}
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] sh: dma-sysfs: add missing put_device() in dma_create_sysfs_files()
2025-12-20 6:28 [PATCH] sh: dma-sysfs: add missing put_device() in dma_create_sysfs_files() Haoxiang Li
@ 2025-12-20 13:56 ` Markus Elfring
2025-12-20 14:11 ` John Paul Adrian Glaubitz
0 siblings, 1 reply; 3+ messages in thread
From: Markus Elfring @ 2025-12-20 13:56 UTC (permalink / raw)
To: Haoxiang Li, linux-sh, Greg Kroah-Hartman,
John Paul Adrian Glaubitz, Kay Sievers, Rich Felker,
Yoshinori Sato
Cc: stable, LKML
> If device_register() fails, call put_device() to drop the device
> reference. Also, call device_unregister() if device_create_file()
> fails.
See also once more:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.19-rc1#n659
You propose to complete the exception handling for two cases.
Is there a need to indicate such a detail in the summary phrase accordingly?
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sh: dma-sysfs: add missing put_device() in dma_create_sysfs_files()
2025-12-20 13:56 ` Markus Elfring
@ 2025-12-20 14:11 ` John Paul Adrian Glaubitz
0 siblings, 0 replies; 3+ messages in thread
From: John Paul Adrian Glaubitz @ 2025-12-20 14:11 UTC (permalink / raw)
To: Markus Elfring, Haoxiang Li, linux-sh, Greg Kroah-Hartman,
Kay Sievers, Rich Felker, Yoshinori Sato
Cc: stable, LKML
Hi Markus,
On Sat, 2025-12-20 at 14:56 +0100, Markus Elfring wrote:
> > If device_register() fails, call put_device() to drop the device
> > reference. Also, call device_unregister() if device_create_file()
> > fails.
>
> See also once more:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.19-rc1#n659
>
>
> You propose to complete the exception handling for two cases.
> Is there a need to indicate such a detail in the summary phrase accordingly?
Maybe I'm completely missing something here, but I find the description short
and reasonable. As the SH maintainer, I haven't started reviewing these patches
themselves yet, I definitely interested to understand what the problem is.
Thanks,
Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-20 14:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-20 6:28 [PATCH] sh: dma-sysfs: add missing put_device() in dma_create_sysfs_files() Haoxiang Li
2025-12-20 13:56 ` Markus Elfring
2025-12-20 14:11 ` John Paul Adrian Glaubitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®