linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [bug report] mm/vmalloc: explicitly identify vm_map_ram area when shown in /proc/vmcoreinfo
@ 2023-01-17 11:03 Dan Carpenter
  2023-01-18  2:03 ` Baoquan He
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-01-17 11:03 UTC (permalink / raw)
  To: bhe; +Cc: linux-mm

Hello Baoquan He,

This static checker warning is related to yesterdays, but more straight
forward to analyze.

The patch ae5dfc510155: "mm/vmalloc: explicitly identify vm_map_ram
area when shown in /proc/vmcoreinfo" from Jan 13, 2023, leads to the
following Smatch static checker warning:

	mm/vmalloc.c:4244 s_show()
	error: we previously assumed 'v' could be null (see line 4241)

mm/vmalloc.c
    4226 static int s_show(struct seq_file *m, void *p)
    4227 {
    4228         struct vmap_area *va;
    4229         struct vm_struct *v;
    4230 
    4231         va = list_entry(p, struct vmap_area, list);
    4232 
    4233         if (!va->vm && (va->flags & VMAP_RAM)) {
                      ^^^^^^     ^^^^^^^^^^^^^^^^^^^^
Assume va->vm is NULL but the VMAP_RAM flag is not set.

    4234                 seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n",
    4235                         (void *)va->va_start, (void *)va->va_end,
    4236                         va->va_end - va->va_start);
    4237 
    4238                 goto final;
    4239         }
    4240 
    4241         v = va->vm;
                 ^^^^^^^^^^
Assignment

    4242 
    4243         seq_printf(m, "0x%pK-0x%pK %7ld",
--> 4244                 v->addr, v->addr + v->size, v->size);
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dead.

    4245 
    4246         if (v->caller)
    4247                 seq_printf(m, " %pS", v->caller);
    4248 

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] mm/vmalloc: explicitly identify vm_map_ram area when shown in /proc/vmcoreinfo
  2023-01-17 11:03 [bug report] mm/vmalloc: explicitly identify vm_map_ram area when shown in /proc/vmcoreinfo Dan Carpenter
@ 2023-01-18  2:03 ` Baoquan He
  0 siblings, 0 replies; 2+ messages in thread
From: Baoquan He @ 2023-01-18  2:03 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-mm

On 01/17/23 at 02:03pm, Dan Carpenter wrote:
> Hello Baoquan He,
> 
> This static checker warning is related to yesterdays, but more straight
> forward to analyze.
> 
> The patch ae5dfc510155: "mm/vmalloc: explicitly identify vm_map_ram
> area when shown in /proc/vmcoreinfo" from Jan 13, 2023, leads to the
> following Smatch static checker warning:
> 
> 	mm/vmalloc.c:4244 s_show()
> 	error: we previously assumed 'v' could be null (see line 4241)

Thanks a lot, Dan. This is a good catch.

Below change should fix it. There are concerns in the patchset thread
where this patch is carried. I will reply and see if I need repost a new
version, or append below draft patch and post.

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 320e3d77a9dd..a0cec3e27e2c 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -4125,10 +4125,11 @@ static int s_show(struct seq_file *m, void *p)
 
 	va = list_entry(p, struct vmap_area, list);
 
-	if (!va->vm && (va->flags & VMAP_RAM)) {
-		seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n",
-			(void *)va->va_start, (void *)va->va_end,
-			va->va_end - va->va_start);
+	if (!va->vm) {
+		if (va->flags & VMAP_RAM) {
+			seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n",
+				(void *)va->va_start, (void *)va->va_end,
+				va->va_end - va->va_start);
 
 		goto final;
 	}

> 
> mm/vmalloc.c
>     4226 static int s_show(struct seq_file *m, void *p)
>     4227 {
>     4228         struct vmap_area *va;
>     4229         struct vm_struct *v;
>     4230 
>     4231         va = list_entry(p, struct vmap_area, list);
>     4232 
>     4233         if (!va->vm && (va->flags & VMAP_RAM)) {
>                       ^^^^^^     ^^^^^^^^^^^^^^^^^^^^
> Assume va->vm is NULL but the VMAP_RAM flag is not set.
> 
>     4234                 seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n",
>     4235                         (void *)va->va_start, (void *)va->va_end,
>     4236                         va->va_end - va->va_start);
>     4237 
>     4238                 goto final;
>     4239         }
>     4240 
>     4241         v = va->vm;
>                  ^^^^^^^^^^
> Assignment
> 
>     4242 
>     4243         seq_printf(m, "0x%pK-0x%pK %7ld",
> --> 4244                 v->addr, v->addr + v->size, v->size);
>                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Dead.
> 
>     4245 
>     4246         if (v->caller)
>     4247                 seq_printf(m, " %pS", v->caller);
>     4248 
> 
> regards,
> dan carpenter
> 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-18  2:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-17 11:03 [bug report] mm/vmalloc: explicitly identify vm_map_ram area when shown in /proc/vmcoreinfo Dan Carpenter
2023-01-18  2:03 ` Baoquan He

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox