* [PATCH -next] spi: s3c64xx: fix reference leak to master in s3c64xx_spi_remove() @ 2016-07-12 11:08 ` weiyj_lk-9Onoh4P/yGk 2016-07-13 4:50 ` Andi Shyti ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: weiyj_lk-9Onoh4P/yGk @ 2016-07-12 11:08 UTC (permalink / raw) To: Kukjin Kim, Krzysztof Kozlowski, Mark Brown Cc: Wei Yongjun, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, linux-spi-u79uwXL29TY76Z2rM5mHXA From: Wei Yongjun <yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY@public.gmane.org> Once a spi_master_get() call succeeds, we need an additional spi_master_put() call to free the memory, otherwise we will leak a reference to master. Fix by removing the unnecessary spi_master_get() call. Signed-off-by: Wei Yongjun <yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY@public.gmane.org> --- drivers/spi/spi-s3c64xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index df88fa1..001c9eb 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -1211,7 +1211,7 @@ err0: static int s3c64xx_spi_remove(struct platform_device *pdev) { - struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); + struct spi_master *master = platform_get_drvdata(pdev); struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); pm_runtime_get_sync(&pdev->dev); -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH -next] spi: s3c64xx: fix reference leak to master in s3c64xx_spi_remove() 2016-07-12 11:08 ` [PATCH -next] spi: s3c64xx: fix reference leak to master in s3c64xx_spi_remove() weiyj_lk-9Onoh4P/yGk @ 2016-07-13 4:50 ` Andi Shyti 2016-07-13 5:36 ` weiyj 2016-07-13 9:17 ` Andi Shyti [not found] ` <1468321722-16568-1-git-send-email-weiyj_lk-9Onoh4P/yGk@public.gmane.org> 2 siblings, 1 reply; 6+ messages in thread From: Andi Shyti @ 2016-07-13 4:50 UTC (permalink / raw) To: weiyj_lk Cc: Kukjin Kim, Krzysztof Kozlowski, Mark Brown, Wei Yongjun, linux-arm-kernel, linux-samsung-soc, linux-spi Hi Wei, > Once a spi_master_get() call succeeds, we need an additional > spi_master_put() call to free the memory, otherwise we will > leak a reference to master. Fix by removing the unnecessary > spi_master_get() call. > > Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> The patch doesn't have anything wrong, but what you write in the description is not what you are doing in the patch. There is no memory allocated in spi_master_get and nothing leaks. Besides master's resources are managed, so that there would not be any need to call spi_master_put(). spi_master_put() has been, indeed, removed in this commit: 91800f0e90050a4db4c77e940796f501e02af8be. But even if you correct the commit log, I don't see much advantage for this patch on its own. Thanks, Andi > --- > drivers/spi/spi-s3c64xx.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c > index df88fa1..001c9eb 100644 > --- a/drivers/spi/spi-s3c64xx.c > +++ b/drivers/spi/spi-s3c64xx.c > @@ -1211,7 +1211,7 @@ err0: > > static int s3c64xx_spi_remove(struct platform_device *pdev) > { > - struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); > + struct spi_master *master = platform_get_drvdata(pdev); > struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); > > pm_runtime_get_sync(&pdev->dev); > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re:Re: [PATCH -next] spi: s3c64xx: fix reference leak to master in s3c64xx_spi_remove() 2016-07-13 4:50 ` Andi Shyti @ 2016-07-13 5:36 ` weiyj [not found] ` <481c6f26.751d.155e2c1d661.Coremail.weiyj_lk-9Onoh4P/yGk@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: weiyj @ 2016-07-13 5:36 UTC (permalink / raw) To: Andi Shyti Cc: Krzysztof Kozlowski, linux-samsung-soc, Mark Brown, linux-spi, Wei Yongjun, Kukjin Kim, linux-arm-kernel Hi Andi, At 2016-07-13 12:50:30, "Andi Shyti" <andi.shyti@samsung.com> wrote: >Hi Wei, > >> Once a spi_master_get() call succeeds, we need an additional >> spi_master_put() call to free the memory, otherwise we will >> leak a reference to master. Fix by removing the unnecessary >> spi_master_get() call. >> >> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> > >The patch doesn't have anything wrong, but what you write in the >description is not what you are doing in the patch. > >There is no memory allocated in spi_master_get and nothing leaks. >Besides master's resources are managed, so that there would >not be any need to call spi_master_put(). > >spi_master_put() has been, indeed, removed in this commit: >91800f0e90050a4db4c77e940796f501e02af8be. > master allocated in spi_alloc_master() need device reference count to zero to be freed. The call sequence spi_alloc_master/spi_register_master/spi_unregister_master is complete; it reduces the device reference count to zero, which results in device memory being freed. In commit 91800f0e90050a4db4c77e940796f501e02af8be, devm_spi_register_master() equal to spi_register_master() and auto call spi_unregister_master() when remove. But remove spi_master_put() will cause the device reference count left no zero, since spi_master_get() is callled at the begin of remove function already. So I think we should either remove the spi_master_get() or add spi_master_put() before return from remove function. Regards, Yongjun Wei ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <481c6f26.751d.155e2c1d661.Coremail.weiyj_lk-9Onoh4P/yGk@public.gmane.org>]
* Re: Re: [PATCH -next] spi: s3c64xx: fix reference leak to master in s3c64xx_spi_remove() [not found] ` <481c6f26.751d.155e2c1d661.Coremail.weiyj_lk-9Onoh4P/yGk@public.gmane.org> @ 2016-07-13 8:34 ` Andi Shyti 0 siblings, 0 replies; 6+ messages in thread From: Andi Shyti @ 2016-07-13 8:34 UTC (permalink / raw) To: weiyj Cc: Kukjin Kim, Krzysztof Kozlowski, Mark Brown, Wei Yongjun, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, linux-spi-u79uwXL29TY76Z2rM5mHXA Hi Wei, > >> Once a spi_master_get() call succeeds, we need an additional > >> spi_master_put() call to free the memory, otherwise we will > >> leak a reference to master. Fix by removing the unnecessary > >> spi_master_get() call. > >> > >> Signed-off-by: Wei Yongjun <yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY@public.gmane.org> > > > >The patch doesn't have anything wrong, but what you write in the > >description is not what you are doing in the patch. > > > >There is no memory allocated in spi_master_get and nothing leaks. > >Besides master's resources are managed, so that there would > >not be any need to call spi_master_put(). > > > >spi_master_put() has been, indeed, removed in this commit: > >91800f0e90050a4db4c77e940796f501e02af8be. > > > > master allocated in spi_alloc_master() need device reference count to zero > to be freed. > > The call sequence spi_alloc_master/spi_register_master/spi_unregister_master > is complete; it reduces the device reference count to zero, which results in > device memory being freed. > > In commit 91800f0e90050a4db4c77e940796f501e02af8be, > devm_spi_register_master() equal to spi_register_master() and auto call > spi_unregister_master() when remove. But remove spi_master_put() > will cause the device reference count left no zero, since spi_master_get() > is callled at the begin of remove function already. > > So I think we should either remove the spi_master_get() or add spi_master_put() > before return from remove function. Yes, you are right, I missed this part :) Thanks, Andi -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -next] spi: s3c64xx: fix reference leak to master in s3c64xx_spi_remove() 2016-07-12 11:08 ` [PATCH -next] spi: s3c64xx: fix reference leak to master in s3c64xx_spi_remove() weiyj_lk-9Onoh4P/yGk 2016-07-13 4:50 ` Andi Shyti @ 2016-07-13 9:17 ` Andi Shyti [not found] ` <1468321722-16568-1-git-send-email-weiyj_lk-9Onoh4P/yGk@public.gmane.org> 2 siblings, 0 replies; 6+ messages in thread From: Andi Shyti @ 2016-07-13 9:17 UTC (permalink / raw) To: weiyj_lk Cc: Kukjin Kim, Krzysztof Kozlowski, Mark Brown, Wei Yongjun, linux-arm-kernel, linux-samsung-soc, linux-spi On Tue, Jul 12, 2016 at 11:08:42AM +0000, weiyj_lk@163.com wrote: > From: Wei Yongjun <yongjun_wei@trendmicro.com.cn> > > Once a spi_master_get() call succeeds, we need an additional > spi_master_put() call to free the memory, otherwise we will > leak a reference to master. Fix by removing the unnecessary > spi_master_get() call. > > Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> After our discussion, I checked it again and feel free to add Reviewed-by: Andi Shyti <andi.shyti@samsung.com> Thanks, Andi > --- > drivers/spi/spi-s3c64xx.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c > index df88fa1..001c9eb 100644 > --- a/drivers/spi/spi-s3c64xx.c > +++ b/drivers/spi/spi-s3c64xx.c > @@ -1211,7 +1211,7 @@ err0: > > static int s3c64xx_spi_remove(struct platform_device *pdev) > { > - struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); > + struct spi_master *master = platform_get_drvdata(pdev); > struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); > > pm_runtime_get_sync(&pdev->dev); > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <1468321722-16568-1-git-send-email-weiyj_lk-9Onoh4P/yGk@public.gmane.org>]
* Applied "spi: s3c64xx: fix reference leak to master in s3c64xx_spi_remove()" to the spi tree [not found] ` <1468321722-16568-1-git-send-email-weiyj_lk-9Onoh4P/yGk@public.gmane.org> @ 2016-07-14 16:33 ` Mark Brown 0 siblings, 0 replies; 6+ messages in thread From: Mark Brown @ 2016-07-14 16:33 UTC (permalink / raw) To: Wei Yongjun Cc: Mark Brown, Kukjin Kim, Krzysztof Kozlowski, Mark Brown, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, linux-spi-u79uwXL29TY76Z2rM5mHXA The patch spi: s3c64xx: fix reference leak to master in s3c64xx_spi_remove() has been applied to the spi tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 9f135787b1d29b0069059b580c1c77965e5e8af4 Mon Sep 17 00:00:00 2001 From: Wei Yongjun <yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY@public.gmane.org> Date: Tue, 12 Jul 2016 11:08:42 +0000 Subject: [PATCH] spi: s3c64xx: fix reference leak to master in s3c64xx_spi_remove() Once a spi_master_get() call succeeds, we need an additional spi_master_put() call to free the memory, otherwise we will leak a reference to master. Fix by removing the unnecessary spi_master_get() call. Signed-off-by: Wei Yongjun <yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY@public.gmane.org> Reviewed-by: Andi Shyti <andi.shyti-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> --- drivers/spi/spi-s3c64xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index df88fa161d8a..001c9ebf884d 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -1211,7 +1211,7 @@ err0: static int s3c64xx_spi_remove(struct platform_device *pdev) { - struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); + struct spi_master *master = platform_get_drvdata(pdev); struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); pm_runtime_get_sync(&pdev->dev); -- 2.8.1 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-07-14 16:33 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <CGME20160712110926epcas1p13bbc88f5867d41d09d9b8c1172a7150b@epcas1p1.samsung.com> 2016-07-12 11:08 ` [PATCH -next] spi: s3c64xx: fix reference leak to master in s3c64xx_spi_remove() weiyj_lk-9Onoh4P/yGk 2016-07-13 4:50 ` Andi Shyti 2016-07-13 5:36 ` weiyj [not found] ` <481c6f26.751d.155e2c1d661.Coremail.weiyj_lk-9Onoh4P/yGk@public.gmane.org> 2016-07-13 8:34 ` Andi Shyti 2016-07-13 9:17 ` Andi Shyti [not found] ` <1468321722-16568-1-git-send-email-weiyj_lk-9Onoh4P/yGk@public.gmane.org> 2016-07-14 16:33 ` Applied "spi: s3c64xx: fix reference leak to master in s3c64xx_spi_remove()" to the spi tree Mark Brown
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).