[PATCH v2] staging: erofs: fix memleak of inode's shared xattr array

2019-02-13 Thread Sheng Yong
If it fails to read a shared xattr page, the inode's shared xattr array
is not freed. The next time the inode's xattr is accessed, the previously
allocated array is leaked.

Signed-off-by: Sheng Yong 
---
v2: * s/node/inode in commit message
* add prefix `staging:' to the subject
---
 drivers/staging/erofs/xattr.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c
index 80dca6a4adbe..e3f8b904a680 100644
--- a/drivers/staging/erofs/xattr.c
+++ b/drivers/staging/erofs/xattr.c
@@ -92,8 +92,11 @@ static int init_inode_xattrs(struct inode *inode)
 
it.page = erofs_get_meta_page(sb,
++it.blkaddr, S_ISDIR(inode->i_mode));
-   if (IS_ERR(it.page))
+   if (IS_ERR(it.page)) {
+   kfree(vi->xattr_shared_xattrs);
+   vi->xattr_shared_xattrs = NULL;
return PTR_ERR(it.page);
+   }
 
it.kaddr = kmap_atomic(it.page);
atomic_map = true;
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] erofs: fix memleak of node's shared xattr array

2019-02-13 Thread Sheng Yong
If it fails to read a shared xattr page, the node's shared xattr array
is not freed. The next time the node's xattr is accessed, the previously
allocated array is leaked.

Signed-off-by: Sheng Yong 
---
 drivers/staging/erofs/xattr.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c
index 80dca6a4adbe..e3f8b904a680 100644
--- a/drivers/staging/erofs/xattr.c
+++ b/drivers/staging/erofs/xattr.c
@@ -92,8 +92,11 @@ static int init_inode_xattrs(struct inode *inode)
 
it.page = erofs_get_meta_page(sb,
++it.blkaddr, S_ISDIR(inode->i_mode));
-   if (IS_ERR(it.page))
+   if (IS_ERR(it.page)) {
+   kfree(vi->xattr_shared_xattrs);
+   vi->xattr_shared_xattrs = NULL;
return PTR_ERR(it.page);
+   }
 
it.kaddr = kmap_atomic(it.page);
atomic_map = true;
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: fbtft: use %zu to avoid compile warning

2015-02-26 Thread Sheng Yong
For value which has size_t type, use %zu to avoid compile warning of
printk format.

Signed-off-by: Sheng Yong shengyo...@huawei.com
---
 drivers/staging/fbtft/fbtft-core.c | 2 +-
 drivers/staging/fbtft/fbtft-io.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fbtft/fbtft-core.c 
b/drivers/staging/fbtft/fbtft-core.c
index 37dcf7e..b82870b 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -1000,7 +1000,7 @@ int fbtft_register_framebuffer(struct fb_info *fb_info)
fbtft_sysfs_init(par);
 
if (par-txbuf.buf)
-   sprintf(text1, , %d KiB %sbuffer memory,
+   sprintf(text1, , %zu KiB %sbuffer memory,
par-txbuf.len  10, par-txbuf.dma ? DMA  : );
if (spi)
sprintf(text2, , spi%d.%d at %d MHz, spi-master-bus_num,
diff --git a/drivers/staging/fbtft/fbtft-io.c b/drivers/staging/fbtft/fbtft-io.c
index 32155a7..9b2f8cf 100644
--- a/drivers/staging/fbtft/fbtft-io.c
+++ b/drivers/staging/fbtft/fbtft-io.c
@@ -59,7 +59,7 @@ int fbtft_write_spi_emulate_9(struct fbtft_par *par, void 
*buf, size_t len)
}
if ((len % 8) != 0) {
dev_err(par-info-device,
-   %s: error: len=%d must be divisible by 8\n,
+   %s: error: len=%zu must be divisible by 8\n,
__func__, len);
return -EINVAL;
}
@@ -106,7 +106,7 @@ int fbtft_read_spi(struct fbtft_par *par, void *buf, size_t 
len)
if (par-startbyte) {
if (len  32) {
dev_err(par-info-device,
-   %s: len=%d can't be larger than 32 when using 
'startbyte'\n,
+   %s: len=%zu can't be larger than 32 when using 
'startbyte'\n,
__func__, len);
return -EINVAL;
}
-- 
1.8.3.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel