* [PATCH] mm/damon/sysfs: eliminate potential uninitialized variable warning
@ 2023-11-06 14:07 Dan Carpenter
2023-11-06 14:41 ` SeongJae Park
2023-11-06 19:05 ` Deepak R Varma
0 siblings, 2 replies; 7+ messages in thread
From: Dan Carpenter @ 2023-11-06 14:07 UTC (permalink / raw)
To: SeongJae Park; +Cc: Andrew Morton, damon, linux-mm, kernel-janitors
The "err" variable is not initialized if damon_target_has_pid(ctx) is
false and sys_target->regions->nr is zero.
Fixes: 0bcd216c4741 ("mm/damon/sysfs: update monitoring target regions for online input commit")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
mm/damon/sysfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index e27846708b5a..1dfa96d4de99 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1172,7 +1172,7 @@ static int damon_sysfs_update_target(struct damon_target *target,
struct damon_ctx *ctx,
struct damon_sysfs_target *sys_target)
{
- int err;
+ int err = 0;
if (damon_target_has_pid(ctx)) {
err = damon_sysfs_update_target_pid(target, sys_target->pid);
--
2.42.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/damon/sysfs: eliminate potential uninitialized variable warning
2023-11-06 14:07 [PATCH] mm/damon/sysfs: eliminate potential uninitialized variable warning Dan Carpenter
@ 2023-11-06 14:41 ` SeongJae Park
2023-11-06 16:23 ` Dan Carpenter
2023-11-06 19:05 ` Deepak R Varma
1 sibling, 1 reply; 7+ messages in thread
From: SeongJae Park @ 2023-11-06 14:41 UTC (permalink / raw)
To: Dan Carpenter
Cc: SeongJae Park, Andrew Morton, damon, linux-mm, kernel-janitors
Hi Dan,
On Mon, 6 Nov 2023 17:07:40 +0300 Dan Carpenter <dan.carpenter@linaro.org> wrote:
> The "err" variable is not initialized if damon_target_has_pid(ctx) is
> false and sys_target->regions->nr is zero.
Thank you for fixing this. I actually noticed this issue from Coverity Weekly
Scan of -next tree (CID 1570878), and was about to send very same fix, but you
were faster :)
>
> Fixes: 0bcd216c4741 ("mm/damon/sysfs: update monitoring target regions for online input commit")
Cc stable?
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: SeongJae Park <sj@kernel.org>
Thanks,
SJ
> ---
> mm/damon/sysfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
> index e27846708b5a..1dfa96d4de99 100644
> --- a/mm/damon/sysfs.c
> +++ b/mm/damon/sysfs.c
> @@ -1172,7 +1172,7 @@ static int damon_sysfs_update_target(struct damon_target *target,
> struct damon_ctx *ctx,
> struct damon_sysfs_target *sys_target)
> {
> - int err;
> + int err = 0;
>
> if (damon_target_has_pid(ctx)) {
> err = damon_sysfs_update_target_pid(target, sys_target->pid);
> --
> 2.42.0
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/damon/sysfs: eliminate potential uninitialized variable warning
2023-11-06 14:41 ` SeongJae Park
@ 2023-11-06 16:23 ` Dan Carpenter
2023-11-06 16:52 ` SeongJae Park
0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2023-11-06 16:23 UTC (permalink / raw)
To: SeongJae Park; +Cc: Andrew Morton, damon, linux-mm, kernel-janitors
On Mon, Nov 06, 2023 at 06:41:37AM -0800, SeongJae Park wrote:
> Hi Dan,
>
> On Mon, 6 Nov 2023 17:07:40 +0300 Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> > The "err" variable is not initialized if damon_target_has_pid(ctx) is
> > false and sys_target->regions->nr is zero.
>
> Thank you for fixing this. I actually noticed this issue from Coverity Weekly
> Scan of -next tree (CID 1570878), and was about to send very same fix, but you
> were faster :)
>
> >
> > Fixes: 0bcd216c4741 ("mm/damon/sysfs: update monitoring target regions for online input commit")
>
> Cc stable?
>
The fixes tag is from last week so I assumed it wasn't in stable yet.
Also to be honest, I wasn't totally positive this bug could occur in
real life.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/damon/sysfs: eliminate potential uninitialized variable warning
2023-11-06 16:23 ` Dan Carpenter
@ 2023-11-06 16:52 ` SeongJae Park
2023-11-07 3:54 ` Dan Carpenter
0 siblings, 1 reply; 7+ messages in thread
From: SeongJae Park @ 2023-11-06 16:52 UTC (permalink / raw)
To: Dan Carpenter
Cc: SeongJae Park, Andrew Morton, damon, linux-mm, kernel-janitors
On Mon, 6 Nov 2023 19:23:47 +0300 Dan Carpenter <dan.carpenter@linaro.org> wrote:
> On Mon, Nov 06, 2023 at 06:41:37AM -0800, SeongJae Park wrote:
> > Hi Dan,
> >
> > On Mon, 6 Nov 2023 17:07:40 +0300 Dan Carpenter <dan.carpenter@linaro.org> wrote:
> >
> > > The "err" variable is not initialized if damon_target_has_pid(ctx) is
> > > false and sys_target->regions->nr is zero.
> >
> > Thank you for fixing this. I actually noticed this issue from Coverity Weekly
> > Scan of -next tree (CID 1570878), and was about to send very same fix, but you
> > were faster :)
> >
> > >
> > > Fixes: 0bcd216c4741 ("mm/damon/sysfs: update monitoring target regions for online input commit")
> >
> > Cc stable?
> >
>
> The fixes tag is from last week so I assumed it wasn't in stable yet.
You're right. But the broken commit is a fix for stable trees, so I was
thinking this fix should also be merged into the stable kernel together. I
think stable maintainers would do that on their own, but I wanted to make sure
by explicitly Cc-ing them.
>
> Also to be honest, I wasn't totally positive this bug could occur in
> real life.
Again, you're right. The uninitialized value can be returned to the caller,
but the caller of the function is not checking the returned value, so no real
problem can occur here.
But I think the unhandling of the return value is a bug itself, that not making
system crash like things but might make user confused, so I was preparing a
followup fix for that, too. So, though the problem the fixes will fix are not
significant, I'd prefer merging this and the followup fix to stable trees if
ok, since those are anyway bug fix, and should be simple to apply. If
something conflicts, I will provide backports.
Thanks,
SJ
>
> regards,
> dan carpenter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/damon/sysfs: eliminate potential uninitialized variable warning
2023-11-06 14:07 [PATCH] mm/damon/sysfs: eliminate potential uninitialized variable warning Dan Carpenter
2023-11-06 14:41 ` SeongJae Park
@ 2023-11-06 19:05 ` Deepak R Varma
2023-11-06 20:49 ` SeongJae Park
1 sibling, 1 reply; 7+ messages in thread
From: Deepak R Varma @ 2023-11-06 19:05 UTC (permalink / raw)
To: Dan Carpenter
Cc: SeongJae Park, Andrew Morton, damon, linux-mm, kernel-janitors
On Mon, Nov 06, 2023 at 05:07:40PM +0300, Dan Carpenter wrote:
> The "err" variable is not initialized if damon_target_has_pid(ctx) is
> false and sys_target->regions->nr is zero.
>
> Fixes: 0bcd216c4741 ("mm/damon/sysfs: update monitoring target regions for online input commit")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Should this be a void function instead as the caller is not checking the return
value.
regards,
deepak.
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/damon/sysfs: eliminate potential uninitialized variable warning
2023-11-06 19:05 ` Deepak R Varma
@ 2023-11-06 20:49 ` SeongJae Park
0 siblings, 0 replies; 7+ messages in thread
From: SeongJae Park @ 2023-11-06 20:49 UTC (permalink / raw)
To: Deepak R Varma
Cc: Dan Carpenter, SeongJae Park, Andrew Morton, damon, linux-mm,
kernel-janitors
Hello Deepak,
On Tue, 7 Nov 2023 00:35:55 +0530 Deepak R Varma <drv@mailo.com> wrote:
> On Mon, Nov 06, 2023 at 05:07:40PM +0300, Dan Carpenter wrote:
> > The "err" variable is not initialized if damon_target_has_pid(ctx) is
> > false and sys_target->regions->nr is zero.
> >
> > Fixes: 0bcd216c4741 ("mm/damon/sysfs: update monitoring target regions for online input commit")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
>
> Should this be a void function instead as the caller is not checking the return
> value.
As I mentioned on a previous reply[1], I think the caller should check the
return value. I will send the fix for that soon.
[1] https://lore.kernel.org/damon/20231106165205.48264-1-sj@kernel.org/
Thanks,
SJ
>
> regards,
> deepak.
>
> >
> >
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/damon/sysfs: eliminate potential uninitialized variable warning
2023-11-06 16:52 ` SeongJae Park
@ 2023-11-07 3:54 ` Dan Carpenter
0 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2023-11-07 3:54 UTC (permalink / raw)
To: SeongJae Park; +Cc: Andrew Morton, damon, linux-mm, kernel-janitors
On Mon, Nov 06, 2023 at 04:52:05PM +0000, SeongJae Park wrote:
> But I think the unhandling of the return value is a bug itself, that not making
> system crash like things but might make user confused, so I was preparing a
> followup fix for that, too. So, though the problem the fixes will fix are not
> significant, I'd prefer merging this and the followup fix to stable trees if
> ok, since those are anyway bug fix, and should be simple to apply. If
> something conflicts, I will provide backports.
Sounds like a plan. Thank you for doing this. :)
regards,
dan carpenter
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-11-07 3:54 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-06 14:07 [PATCH] mm/damon/sysfs: eliminate potential uninitialized variable warning Dan Carpenter
2023-11-06 14:41 ` SeongJae Park
2023-11-06 16:23 ` Dan Carpenter
2023-11-06 16:52 ` SeongJae Park
2023-11-07 3:54 ` Dan Carpenter
2023-11-06 19:05 ` Deepak R Varma
2023-11-06 20:49 ` SeongJae Park
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).