linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2] mm/shmem.c: check the return value of mpol_to_str()
@ 2013-09-19  0:31 Chen,Gang( 陈刚)
  0 siblings, 0 replies; 30+ messages in thread
From: Chen,Gang( 陈刚) @ 2013-09-19  0:31 UTC (permalink / raw)
  To: David Rientjes
  Cc: KOSAKI Motohiro, KOSAKI Motohiro, riel, hughd, xemul, Wanpeng Li,
	Cyrill Gorcunov, linux-mm, Andrew Morton

[-- Attachment #1: Type: text/html, Size: 5029 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread
* [PATCH] mm/shmem.c: check the return value of mpol_to_str()
@ 2013-08-22  1:04 Chen Gang
  2013-09-05  0:24 ` [PATCH v2] " Chen Gang
  0 siblings, 1 reply; 30+ messages in thread
From: Chen Gang @ 2013-08-22  1:04 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Mel Gorman, kosaki.motohiro, riel, hughd, xemul, rientjes,
	Wanpeng Li, Cyrill Gorcunov, linux-mm, linux-kernel

mpol_to_str() may fail, and not fill the buffer (e.g. -EINVAL), so need
check about it, or buffer may not be zero based, and next seq_printf()
will cause issue.

Also need let shmem_show_mpol() return value, since it may fail.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 mm/shmem.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index f00c1c1..b4d44db 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -883,16 +883,20 @@ redirty:
 
 #ifdef CONFIG_NUMA
 #ifdef CONFIG_TMPFS
-static void shmem_show_mpol(struct seq_file *seq, struct mempolicy *mpol)
+static int shmem_show_mpol(struct seq_file *seq, struct mempolicy *mpol)
 {
 	char buffer[64];
+	int ret;
 
 	if (!mpol || mpol->mode == MPOL_DEFAULT)
-		return;		/* show nothing */
+		return 0;		/* show nothing */
 
-	mpol_to_str(buffer, sizeof(buffer), mpol);
+	ret = mpol_to_str(buffer, sizeof(buffer), mpol);
+	if (ret < 0)
+		return ret;
 
 	seq_printf(seq, ",mpol=%s", buffer);
+	return 0;
 }
 
 static struct mempolicy *shmem_get_sbmpol(struct shmem_sb_info *sbinfo)
@@ -951,8 +955,9 @@ static struct page *shmem_alloc_page(gfp_t gfp,
 }
 #else /* !CONFIG_NUMA */
 #ifdef CONFIG_TMPFS
-static inline void shmem_show_mpol(struct seq_file *seq, struct mempolicy *mpol)
+static inline int shmem_show_mpol(struct seq_file *seq, struct mempolicy *mpol)
 {
+	return 0;
 }
 #endif /* CONFIG_TMPFS */
 
@@ -2555,8 +2560,7 @@ static int shmem_show_options(struct seq_file *seq, struct dentry *root)
 	if (!gid_eq(sbinfo->gid, GLOBAL_ROOT_GID))
 		seq_printf(seq, ",gid=%u",
 				from_kgid_munged(&init_user_ns, sbinfo->gid));
-	shmem_show_mpol(seq, sbinfo->mpol);
-	return 0;
+	return shmem_show_mpol(seq, sbinfo->mpol);
 }
 #endif /* CONFIG_TMPFS */
 
-- 
1.7.7.6

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2013-09-24  2:29 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20130919003142.B72EC1840296@intranet.asianux.com>
2013-09-23 21:46 ` [PATCH v2] mm/shmem.c: check the return value of mpol_to_str() David Rientjes
2013-09-24  2:28   ` Chen Gang
2013-09-19  0:31 Chen,Gang( 陈刚)
  -- strict thread matches above, loose matches on Subject: below --
2013-08-22  1:04 [PATCH] " Chen Gang
2013-09-05  0:24 ` [PATCH v2] " Chen Gang
2013-09-09 20:30   ` David Rientjes
2013-09-10  0:47     ` Chen Gang
2013-09-10  6:43       ` David Rientjes
2013-09-10  7:01         ` Chen Gang
2013-09-12  0:33           ` David Rientjes
2013-09-12  2:19             ` KOSAKI Motohiro
2013-09-12  3:13               ` Chen Gang
2013-09-13 21:12               ` David Rientjes
2013-09-14  2:51                 ` KOSAKI Motohiro
2013-09-16  3:27                   ` Chen Gang
2013-09-16 20:13                     ` David Rientjes
2013-09-17  0:45                       ` Chen Gang
2013-09-17 22:51                         ` David Rientjes
2013-09-18  1:20                           ` Chen Gang
2013-09-12  3:02             ` Chen Gang
2013-09-12 18:19               ` KOSAKI Motohiro
2013-09-13  2:23                 ` Chen Gang
2013-09-13 16:50                   ` KOSAKI Motohiro
2013-09-16  2:55                     ` Chen Gang
2013-09-16 16:16                       ` KOSAKI Motohiro
2013-09-17  1:10                         ` Chen Gang
2013-09-17 22:53                           ` David Rientjes
2013-09-18  1:37                             ` Chen Gang
2013-09-18 22:17                               ` David Rientjes
2013-09-13 21:14               ` David Rientjes
2013-09-16  3:17                 ` Chen Gang

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