[PATCH] media: atomisp: remove redundant NULL check of "params"

2020-11-17 Thread Ding Xiang
The check result of (!A || (A && B)) is equivalent to (!A || B),
so remove redundant NULL check of "params"

Signed-off-by: Ding Xiang 
---
 drivers/staging/media/atomisp/pci/sh_css_params.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_params.c 
b/drivers/staging/media/atomisp/pci/sh_css_params.c
index 24fc497bd491..9eb02f463eba 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_params.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_params.c
@@ -4649,10 +4649,8 @@ ia_css_dvs2_6axis_config_allocate(const struct 
ia_css_stream *stream)
params = stream->isp_params_configs;
 
/* Backward compatibility by default consider pipe as Video*/
-   if (!params || (params &&
-   !params->pipe_dvs_6axis_config[IA_CSS_PIPE_ID_VIDEO])) {
+   if (!params || !params->pipe_dvs_6axis_config[IA_CSS_PIPE_ID_VIDEO])
goto err;
-   }
 
dvs_config = kvcalloc(1, sizeof(struct ia_css_dvs_6axis_config),
  GFP_KERNEL);
-- 
2.28.0





[PATCH] staging: fieldbus: use kobj_to_dev() to get device

2020-11-16 Thread Ding Xiang
Use kobj_to_dev() instead of container_of()

Signed-off-by: Ding Xiang 
---
 drivers/staging/fieldbus/dev_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fieldbus/dev_core.c 
b/drivers/staging/fieldbus/dev_core.c
index 1ba0234cc60d..5aab734606ea 100644
--- a/drivers/staging/fieldbus/dev_core.c
+++ b/drivers/staging/fieldbus/dev_core.c
@@ -134,7 +134,7 @@ static struct attribute *fieldbus_attrs[] = {
 static umode_t fieldbus_is_visible(struct kobject *kobj, struct attribute 
*attr,
   int n)
 {
-   struct device *dev = container_of(kobj, struct device, kobj);
+   struct device *dev = kobj_to_dev(kobj);
struct fieldbus_dev *fb = dev_get_drvdata(dev);
umode_t mode = attr->mode;
 
-- 
2.28.0





[PATCH] loop: fix passing zero to 'PTR_ERR' warning

2020-06-24 Thread Ding Xiang
Fix a static code checker warning:
drivers/block/loop.c:798 loop_attr_backing_file_show()
warn: passing zero to 'PTR_ERR'

Signed-off-by: Ding Xiang 
---
 drivers/block/loop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 475e1a7..bcada87 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -795,7 +795,7 @@ static ssize_t loop_attr_backing_file_show(struct 
loop_device *lo, char *buf)
spin_unlock_irq(>lo_lock);
 
if (IS_ERR_OR_NULL(p))
-   ret = PTR_ERR(p);
+   ret = PTR_ERR_OR_ZERO(p);
else {
ret = strlen(p);
memmove(buf, p, ret);
-- 
2.7.4





[PATCH] virtio_mmio: remove redundant dev_err message

2019-09-24 Thread Ding Xiang
platform_get_irq already contains error message, so remove
the redundant dev_err message

Signed-off-by: Ding Xiang 
---
 drivers/virtio/virtio_mmio.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index e09edb5..c4b9f25 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -466,10 +466,8 @@ static int vm_find_vqs(struct virtio_device *vdev, 
unsigned nvqs,
int irq = platform_get_irq(vm_dev->pdev, 0);
int i, err, queue_idx = 0;
 
-   if (irq < 0) {
-   dev_err(>dev, "Cannot get IRQ resource\n");
+   if (irq < 0)
return irq;
-   }
 
err = request_irq(irq, vm_interrupt, IRQF_SHARED,
dev_name(>dev), vm_dev);
-- 
1.9.1





[PATCH] remoteproc: debug: Remove unneeded NULL check

2019-09-23 Thread Ding Xiang
debugfs_remove_recursive will do NULL check, so remove
the redundant null check

Signed-off-by: Ding Xiang 
---
 drivers/remoteproc/remoteproc_debugfs.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_debugfs.c 
b/drivers/remoteproc/remoteproc_debugfs.c
index 8cd4a0a..dd93cf0 100644
--- a/drivers/remoteproc/remoteproc_debugfs.c
+++ b/drivers/remoteproc/remoteproc_debugfs.c
@@ -333,9 +333,6 @@ struct dentry *rproc_create_trace_file(const char *name, 
struct rproc *rproc,
 
 void rproc_delete_debug_dir(struct rproc *rproc)
 {
-   if (!rproc->dbg_dir)
-   return;
-
debugfs_remove_recursive(rproc->dbg_dir);
 }
 
-- 
1.9.1





[PATCH V2] ovl: Fix dereferencing possible ERR_PTR()

2019-09-11 Thread Ding Xiang
if ovl_encode_real_fh() fails, no memory was allocated
and the error in the error-valued pointer should be returned.

V1->V2: fix SHA1 length problem

Fixes: 9b6faee07470 ("ovl: check ERR_PTR() return value from ovl_encode_fh()")
Signed-off-by: Ding Xiang 
---
 fs/overlayfs/export.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c
index cb8ec1f..50ade19 100644
--- a/fs/overlayfs/export.c
+++ b/fs/overlayfs/export.c
@@ -229,7 +229,7 @@ static int ovl_d_to_fh(struct dentry *dentry, char *buf, 
int buflen)
ovl_dentry_upper(dentry), !enc_lower);
err = PTR_ERR(fh);
if (IS_ERR(fh))
-   goto fail;
+   return err;
 
err = -EOVERFLOW;
if (fh->len > buflen)
-- 
1.9.1





[PATCH] ath9k: remove unneeded variable

2019-09-10 Thread Ding Xiang
"len" is unneeded,just return 0

Signed-off-by: Ding Xiang 
---
 drivers/net/wireless/ath/ath9k/gpio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/gpio.c 
b/drivers/net/wireless/ath/ath9k/gpio.c
index b457e52..f3d1bc0 100644
--- a/drivers/net/wireless/ath/ath9k/gpio.c
+++ b/drivers/net/wireless/ath/ath9k/gpio.c
@@ -498,14 +498,13 @@ static int ath9k_dump_legacy_btcoex(struct ath_softc *sc, 
u8 *buf, u32 size)
 {
 
struct ath_btcoex *btcoex = >btcoex;
-   u32 len = 0;
 
ATH_DUMP_BTCOEX("Stomp Type", btcoex->bt_stomp_type);
ATH_DUMP_BTCOEX("BTCoex Period (msec)", btcoex->btcoex_period);
ATH_DUMP_BTCOEX("Duty Cycle", btcoex->duty_cycle);
ATH_DUMP_BTCOEX("BT Wait time", btcoex->bt_wait_time);
 
-   return len;
+   return 0;
 }
 
 int ath9k_dump_btcoex(struct ath_softc *sc, u8 *buf, u32 size)
-- 
1.9.1





[PATCH] fpga: remove redundant dev_err message

2019-09-10 Thread Ding Xiang
devm_ioremap_resource already contains error message, so remove
the redundant dev_err message

Signed-off-by: Ding Xiang 
---
 drivers/fpga/ts73xx-fpga.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/fpga/ts73xx-fpga.c b/drivers/fpga/ts73xx-fpga.c
index 9a17fe9..2888ff0 100644
--- a/drivers/fpga/ts73xx-fpga.c
+++ b/drivers/fpga/ts73xx-fpga.c
@@ -119,10 +119,8 @@ static int ts73xx_fpga_probe(struct platform_device *pdev)
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
priv->io_base = devm_ioremap_resource(kdev, res);
-   if (IS_ERR(priv->io_base)) {
-   dev_err(kdev, "unable to remap registers\n");
+   if (IS_ERR(priv->io_base))
return PTR_ERR(priv->io_base);
-   }
 
mgr = devm_fpga_mgr_create(kdev, "TS-73xx FPGA Manager",
   _fpga_ops, priv);
-- 
1.9.1





[PATCH] ocfs2: Fix passing zero to 'PTR_ERR' warning

2019-09-09 Thread Ding Xiang
Fix a static code checker warning:
fs/ocfs2/acl.c:331
ocfs2_acl_chmod() warn: passing zero to 'PTR_ERR'

Fixes: 5ee0fbd50fd ("ocfs2: revert using ocfs2_acl_chmod to avoid inode cluster 
lock hang")
Signed-off-by: Ding Xiang 
---
 fs/ocfs2/acl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
index 3e7da39..bb981ec 100644
--- a/fs/ocfs2/acl.c
+++ b/fs/ocfs2/acl.c
@@ -327,8 +327,8 @@ int ocfs2_acl_chmod(struct inode *inode, struct buffer_head 
*bh)
down_read(_I(inode)->ip_xattr_sem);
acl = ocfs2_get_acl_nolock(inode, ACL_TYPE_ACCESS, bh);
up_read(_I(inode)->ip_xattr_sem);
-   if (IS_ERR(acl) || !acl)
-   return PTR_ERR(acl);
+   if (IS_ERR_OR_NULL(acl))
+   return PTR_ERR_OR_ZERO(acl);
ret = __posix_acl_chmod(, GFP_KERNEL, inode->i_mode);
if (ret)
return ret;
-- 
1.9.1





[PATCH] ovl: Fix dereferencing possible ERR_PTR()

2019-09-09 Thread Ding Xiang
if ovl_encode_real_fh() fails, no memory was allocated
and the error in the error-valued pointer should be returned.

Fixes: 9b6faee0747 ("ovl: check ERR_PTR() return value from ovl_encode_fh()")
Signed-off-by: Ding Xiang 
---
 fs/overlayfs/export.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c
index cb8ec1f..50ade19 100644
--- a/fs/overlayfs/export.c
+++ b/fs/overlayfs/export.c
@@ -229,7 +229,7 @@ static int ovl_d_to_fh(struct dentry *dentry, char *buf, 
int buflen)
ovl_dentry_upper(dentry), !enc_lower);
err = PTR_ERR(fh);
if (IS_ERR(fh))
-   goto fail;
+   return err;
 
err = -EOVERFLOW;
if (fh->len > buflen)
-- 
1.9.1





[PATCH] gpio: ixp4xx: remove redundant dev_err message

2019-07-31 Thread Ding Xiang
devm_ioremap_resource already contains error message, so remove
the redundant dev_err message

Signed-off-by: Ding Xiang 
---
 drivers/gpio/gpio-ixp4xx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-ixp4xx.c b/drivers/gpio/gpio-ixp4xx.c
index 670c2a8..2b2b89b 100644
--- a/drivers/gpio/gpio-ixp4xx.c
+++ b/drivers/gpio/gpio-ixp4xx.c
@@ -321,10 +321,8 @@ static int ixp4xx_gpio_probe(struct platform_device *pdev)
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
g->base = devm_ioremap_resource(dev, res);
-   if (IS_ERR(g->base)) {
-   dev_err(dev, "ioremap error\n");
+   if (IS_ERR(g->base))
return PTR_ERR(g->base);
-   }
 
/*
 * Make sure GPIO 14 and 15 are NOT used as clocks but GPIO on
-- 
1.9.1





[PATCH] myri10ge: remove unneeded variable

2019-07-31 Thread Ding Xiang
"error" is unneeded,just return 0

Signed-off-by: Ding Xiang 
---
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c 
b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
index d8b7fba..a4165e1 100644
--- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
+++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
@@ -3037,7 +3037,6 @@ static int myri10ge_set_mac_address(struct net_device 
*dev, void *addr)
 static int myri10ge_change_mtu(struct net_device *dev, int new_mtu)
 {
struct myri10ge_priv *mgp = netdev_priv(dev);
-   int error = 0;
 
netdev_info(dev, "changing mtu from %d to %d\n", dev->mtu, new_mtu);
if (mgp->running) {
@@ -3049,7 +3048,7 @@ static int myri10ge_change_mtu(struct net_device *dev, 
int new_mtu)
} else
dev->mtu = new_mtu;
 
-   return error;
+   return 0;
 }
 
 /*
-- 
1.9.1





[PATCH] net: ag71xx: use resource_size for the ioremap size

2019-07-29 Thread Ding Xiang
use resource_size to calcuate ioremap size and make
the code simpler.

Signed-off-by: Ding Xiang 
---
 drivers/net/ethernet/atheros/ag71xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/atheros/ag71xx.c 
b/drivers/net/ethernet/atheros/ag71xx.c
index 8b69d0d..77542bd 100644
--- a/drivers/net/ethernet/atheros/ag71xx.c
+++ b/drivers/net/ethernet/atheros/ag71xx.c
@@ -1686,7 +1686,7 @@ static int ag71xx_probe(struct platform_device *pdev)
}
 
ag->mac_base = devm_ioremap_nocache(>dev, res->start,
-   res->end - res->start + 1);
+   resource_size(res));
if (!ag->mac_base) {
err = -ENOMEM;
goto err_free;
-- 
1.9.1





[PATCH] nvmem: remove redundant dev_err message

2019-07-25 Thread Ding Xiang
devm_ioremap_resource already contains error message, so remove
the redundant dev_err message

Signed-off-by: Ding Xiang 
---
 drivers/nvmem/bcm-ocotp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/nvmem/bcm-ocotp.c b/drivers/nvmem/bcm-ocotp.c
index a809751..460a220 100644
--- a/drivers/nvmem/bcm-ocotp.c
+++ b/drivers/nvmem/bcm-ocotp.c
@@ -271,10 +271,8 @@ static int bcm_otpc_probe(struct platform_device *pdev)
/* Get OTP base address register. */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
priv->base = devm_ioremap_resource(dev, res);
-   if (IS_ERR(priv->base)) {
-   dev_err(dev, "unable to map I/O memory\n");
+   if (IS_ERR(priv->base))
return PTR_ERR(priv->base);
-   }
 
/* Enable CPU access to OTPC. */
writel(readl(priv->base + OTPC_MODE_REG_OFFSET) |
-- 
1.9.1





[PATCH] mailbox: fix return value check in zynqmp_ipi_mbox_probe

2019-07-25 Thread Ding Xiang
If devm_ioremap() failed, it will return NULL pointer not
ERR_PTR(). So, use NULL test instead of IS_ERR() test.

Signed-off-by: Ding Xiang 
---
 drivers/mailbox/zynqmp-ipi-mailbox.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/mailbox/zynqmp-ipi-mailbox.c 
b/drivers/mailbox/zynqmp-ipi-mailbox.c
index 86887c9..660a8d2 100644
--- a/drivers/mailbox/zynqmp-ipi-mailbox.c
+++ b/drivers/mailbox/zynqmp-ipi-mailbox.c
@@ -504,9 +504,9 @@ static int zynqmp_ipi_mbox_probe(struct zynqmp_ipi_mbox 
*ipi_mbox,
mchan->req_buf_size = resource_size();
mchan->req_buf = devm_ioremap(mdev, res.start,
  mchan->req_buf_size);
-   if (IS_ERR(mchan->req_buf)) {
+   if (!mchan->req_buf) {
dev_err(mdev, "Unable to map IPI buffer I/O memory\n");
-   ret = PTR_ERR(mchan->req_buf);
+   ret = -ENOMEM;
return ret;
}
} else if (ret != -ENODEV) {
@@ -520,9 +520,9 @@ static int zynqmp_ipi_mbox_probe(struct zynqmp_ipi_mbox 
*ipi_mbox,
mchan->resp_buf_size = resource_size();
mchan->resp_buf = devm_ioremap(mdev, res.start,
   mchan->resp_buf_size);
-   if (IS_ERR(mchan->resp_buf)) {
+   if (!mchan->resp_buf) {
dev_err(mdev, "Unable to map IPI buffer I/O memory\n");
-   ret = PTR_ERR(mchan->resp_buf);
+   ret = -ENOMEM;
return ret;
}
} else if (ret != -ENODEV) {
@@ -543,9 +543,9 @@ static int zynqmp_ipi_mbox_probe(struct zynqmp_ipi_mbox 
*ipi_mbox,
mchan->req_buf_size = resource_size();
mchan->req_buf = devm_ioremap(mdev, res.start,
  mchan->req_buf_size);
-   if (IS_ERR(mchan->req_buf)) {
+   if (!mchan->req_buf) {
dev_err(mdev, "Unable to map IPI buffer I/O memory\n");
-   ret = PTR_ERR(mchan->req_buf);
+   ret = -ENOMEM;
return ret;
}
} else if (ret != -ENODEV) {
@@ -559,9 +559,9 @@ static int zynqmp_ipi_mbox_probe(struct zynqmp_ipi_mbox 
*ipi_mbox,
mchan->resp_buf_size = resource_size();
mchan->resp_buf = devm_ioremap(mdev, res.start,
   mchan->resp_buf_size);
-   if (IS_ERR(mchan->resp_buf)) {
+   if (!mchan->resp_buf) {
dev_err(mdev, "Unable to map IPI buffer I/O memory\n");
-   ret = PTR_ERR(mchan->resp_buf);
+   ret = -ENOMEM;
return ret;
}
} else if (ret != -ENODEV) {
-- 
1.9.1





[PATCH] ptp: ptp_dte: remove redundant dev_err message

2019-07-23 Thread Ding Xiang
devm_ioremap_resource already contains error message, so remove
the redundant dev_err message

Signed-off-by: Ding Xiang 
---
 drivers/ptp/ptp_dte.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/ptp/ptp_dte.c b/drivers/ptp/ptp_dte.c
index 5b6393e..0dcfdc8 100644
--- a/drivers/ptp/ptp_dte.c
+++ b/drivers/ptp/ptp_dte.c
@@ -248,11 +248,8 @@ static int ptp_dte_probe(struct platform_device *pdev)
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
ptp_dte->regs = devm_ioremap_resource(dev, res);
-   if (IS_ERR(ptp_dte->regs)) {
-   dev_err(dev,
-   "%s: io remap failed\n", __func__);
+   if (IS_ERR(ptp_dte->regs))
return PTR_ERR(ptp_dte->regs);
-   }
 
spin_lock_init(_dte->lock);
 
-- 
1.9.1





[PATCH] ALSA: ac97: Fix double free of ac97_codec_device

2019-07-23 Thread Ding Xiang
put_device will call ac97_codec_release to free
ac97_codec_device and other resources, so remove the kfree
and other redundant code.

Signed-off-by: Ding Xiang 
---
 sound/ac97/bus.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/sound/ac97/bus.c b/sound/ac97/bus.c
index 7b977b7..7985dd8 100644
--- a/sound/ac97/bus.c
+++ b/sound/ac97/bus.c
@@ -122,17 +122,12 @@ static int ac97_codec_add(struct ac97_controller 
*ac97_ctrl, int idx,
  vendor_id);
 
ret = device_add(>dev);
-   if (ret)
-   goto err_free_codec;
+   if (ret) {
+   put_device(>dev);
+   return ret;
+   }
 
return 0;
-err_free_codec:
-   of_node_put(codec->dev.of_node);
-   put_device(>dev);
-   kfree(codec);
-   ac97_ctrl->codecs[idx] = NULL;
-
-   return ret;
 }
 
 unsigned int snd_ac97_bus_scan_one(struct ac97_controller *adrv,
-- 
1.9.1





[PATCH] libfs: fix obsolete function

2019-07-18 Thread Ding Xiang
simple_strtoll is obsolete, and use kstrtoll instead

Signed-off-by: Ding Xiang 
---
 fs/libfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index 7e52e77..69cc01d 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -883,7 +883,8 @@ ssize_t simple_attr_write(struct file *file, const char 
__user *buf,
goto out;
 
attr->set_buf[size] = '\0';
-   val = simple_strtoll(attr->set_buf, NULL, 0);
+   if (kstrtoll(attr->set_buf, 0, ))
+   return -EINVAL;
ret = attr->set(attr->data, val);
if (ret == 0)
ret = len; /* on success, claim we got the whole input */
-- 
1.9.1





[PATCH] pwm: sifive: remove redundant dev_err message

2019-07-18 Thread Ding Xiang
devm_ioremap_resource already contains error message, so remove
the redundant dev_err message

Signed-off-by: Ding Xiang 
---
 drivers/pwm/pwm-sifive.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c
index a7c107f..bb4f02c 100644
--- a/drivers/pwm/pwm-sifive.c
+++ b/drivers/pwm/pwm-sifive.c
@@ -250,10 +250,8 @@ static int pwm_sifive_probe(struct platform_device *pdev)
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
ddata->regs = devm_ioremap_resource(dev, res);
-   if (IS_ERR(ddata->regs)) {
-   dev_err(dev, "Unable to map IO resources\n");
+   if (IS_ERR(ddata->regs))
return PTR_ERR(ddata->regs);
-   }
 
ddata->clk = devm_clk_get(dev, NULL);
if (IS_ERR(ddata->clk)) {
-- 
1.9.1





[PATCH] spi: remove redundant put_device

2019-07-17 Thread Ding Xiang
device_unregister will call put_device,
so remove the redundant put_device

Signed-off-by: Ding Xiang 
---
 drivers/spi/spi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 75ac046..d753689 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2133,11 +2133,9 @@ static ssize_t spi_slave_store(struct device *dev,
return -EINVAL;
 
child = device_find_child(>dev, NULL, match_true);
-   if (child) {
+   if (child)
/* Remove registered slave */
device_unregister(child);
-   put_device(child);
-   }
 
if (strcmp(name, "(null)")) {
/* Register new slave */
-- 
1.9.1





[PATCH] stm class: Fix a double free of stm_source_device

2019-07-17 Thread Ding Xiang
put_device will call stm_source_device_release to free
stm_source_device, so remove the kfree.

Signed-off-by: Ding Xiang 
---
 drivers/hwtracing/stm/core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index e55b902..181e7ff 100644
--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -1276,7 +1276,6 @@ int stm_source_register_device(struct device *parent,
 
 err:
put_device(>dev);
-   kfree(src);
 
return err;
 }
-- 
1.9.1





[PATCH] ata: libahci_platform: remove redundant dev_err message

2019-07-16 Thread Ding Xiang
devm_ioremap_resource already contains error message, so remove
the redundant dev_err message

Signed-off-by: Ding Xiang 
---
 drivers/ata/libahci_platform.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
index 72312ad..3a36e76 100644
--- a/drivers/ata/libahci_platform.c
+++ b/drivers/ata/libahci_platform.c
@@ -408,7 +408,6 @@ struct ahci_host_priv *ahci_platform_get_resources(struct 
platform_device *pdev,
hpriv->mmio = devm_ioremap_resource(dev,
  platform_get_resource(pdev, IORESOURCE_MEM, 0));
if (IS_ERR(hpriv->mmio)) {
-   dev_err(dev, "no mmio space\n");
rc = PTR_ERR(hpriv->mmio);
goto err_out;
}
-- 
1.9.1





[PATCH] NFS: fix 'passing zero to PTR_ERR()' warning

2019-07-16 Thread Ding Xiang
Fix a static code checker warning:
fs/nfs/nfs4idmap.c:331
nfs_idmap_get_key() warn: passing zero to 'PTR_ERR'

Signed-off-by: Ding Xiang 
---
 fs/nfs/nfs4idmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c
index 1e72963..f71bb7f 100644
--- a/fs/nfs/nfs4idmap.c
+++ b/fs/nfs/nfs4idmap.c
@@ -328,7 +328,7 @@ static ssize_t nfs_idmap_get_key(const char *name, size_t 
namelen,
 
payload = user_key_payload_rcu(rkey);
if (IS_ERR_OR_NULL(payload)) {
-   ret = PTR_ERR(payload);
+   ret = PTR_ERR_OR_ZERO(payload);
goto out_up;
}
 
-- 
1.9.1





[PATCH] scsi: Remove unreachable code

2019-07-04 Thread Ding Xiang
The return code after switch default is unreachable,
so remove it.

Signed-off-by: Ding Xiang 
---
 drivers/scsi/scsi_error.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index bfa569f..12180f0 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1909,7 +1909,6 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
default:
return FAILED;
}
-   return FAILED;
 
 maybe_retry:
 
-- 
1.9.1





[PATCH] FMC: fix 'passing zero to PTR_ERR()' warning

2019-06-20 Thread Ding Xiang
Fix a static code checker warning:
drivers/fmc/fmc-debug.c:155
fmc_debug_init() warn: passing zero to 'PTR_ERR'

Signed-off-by: Ding Xiang 
---
 drivers/fmc/fmc-debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/fmc/fmc-debug.c b/drivers/fmc/fmc-debug.c
index 1734c7c..dd33951 100644
--- a/drivers/fmc/fmc-debug.c
+++ b/drivers/fmc/fmc-debug.c
@@ -152,7 +152,7 @@ int fmc_debug_init(struct fmc_device *fmc)
fmc->dbg_dir = debugfs_create_dir(dev_name(>dev), NULL);
if (IS_ERR_OR_NULL(fmc->dbg_dir)) {
pr_err("FMC: Cannot create debugfs\n");
-   return PTR_ERR(fmc->dbg_dir);
+   return PTR_ERR_OR_ZERO(fmc->dbg_dir);
}
 
fmc->dbg_sdb_dump = debugfs_create_file(FMC_DBG_SDB_DUMP, 0444,
-- 
1.9.1





[PATCH] fireware: Remove always true condition

2019-06-20 Thread Ding Xiang
The range of max_hops is 0~15 and gap_count_table size is 16,
so the condition is always true, just remove it.

Signed-off-by: Ding Xiang 
---
 drivers/firewire/core-card.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
index 54be881..3489d00 100644
--- a/drivers/firewire/core-card.c
+++ b/drivers/firewire/core-card.c
@@ -462,8 +462,7 @@ static void bm_work(struct work_struct *work)
 * Pick a gap count from 1394a table E-1.  The table doesn't cover
 * the typically much larger 1394b beta repeater delays though.
 */
-   if (!card->beta_repeaters_present &&
-   root_node->max_hops < ARRAY_SIZE(gap_count_table))
+   if (!card->beta_repeaters_present)
gap_count = gap_count_table[root_node->max_hops];
else
gap_count = 63;
-- 
1.9.1





[PATCH] slimbus: remove redundant dev_err message

2019-06-18 Thread Ding Xiang
devm_ioremap_resource already contains error message, so remove
the redundant dev_err message

Signed-off-by: Ding Xiang 
---
 drivers/slimbus/qcom-ctrl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/slimbus/qcom-ctrl.c b/drivers/slimbus/qcom-ctrl.c
index ad3e2e23..a444badd 100644
--- a/drivers/slimbus/qcom-ctrl.c
+++ b/drivers/slimbus/qcom-ctrl.c
@@ -528,10 +528,8 @@ static int qcom_slim_probe(struct platform_device *pdev)
 
slim_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ctrl");
ctrl->base = devm_ioremap_resource(ctrl->dev, slim_mem);
-   if (IS_ERR(ctrl->base)) {
-   dev_err(>dev, "IOremap failed\n");
+   if (IS_ERR(ctrl->base))
return PTR_ERR(ctrl->base);
-   }
 
sctrl->set_laddr = qcom_set_laddr;
sctrl->xfer_msg = qcom_xfer_msg;
-- 
1.9.1





[PATCH] media: rc: remove redundant dev_err message

2019-06-18 Thread Ding Xiang
devm_ioremap_resource already contains error message, so remove
the redundant dev_err message

Signed-off-by: Ding Xiang 
---
 drivers/media/rc/meson-ir.c  | 4 +---
 drivers/media/rc/mtk-cir.c   | 4 +---
 drivers/media/rc/sunxi-cir.c | 1 -
 3 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/media/rc/meson-ir.c b/drivers/media/rc/meson-ir.c
index 9e1a978..bdcf9e9 100644
--- a/drivers/media/rc/meson-ir.c
+++ b/drivers/media/rc/meson-ir.c
@@ -113,10 +113,8 @@ static int meson_ir_probe(struct platform_device *pdev)
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
ir->reg = devm_ioremap_resource(dev, res);
-   if (IS_ERR(ir->reg)) {
-   dev_err(dev, "failed to map registers\n");
+   if (IS_ERR(ir->reg))
return PTR_ERR(ir->reg);
-   }
 
irq = platform_get_irq(pdev, 0);
if (irq < 0) {
diff --git a/drivers/media/rc/mtk-cir.c b/drivers/media/rc/mtk-cir.c
index 46101ef..50fb0ae 100644
--- a/drivers/media/rc/mtk-cir.c
+++ b/drivers/media/rc/mtk-cir.c
@@ -320,10 +320,8 @@ static int mtk_ir_probe(struct platform_device *pdev)
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
ir->base = devm_ioremap_resource(dev, res);
-   if (IS_ERR(ir->base)) {
-   dev_err(dev, "failed to map registers\n");
+   if (IS_ERR(ir->base))
return PTR_ERR(ir->base);
-   }
 
ir->rc = devm_rc_allocate_device(dev, RC_DRIVER_IR_RAW);
if (!ir->rc) {
diff --git a/drivers/media/rc/sunxi-cir.c b/drivers/media/rc/sunxi-cir.c
index a48f685..aa719d0 100644
--- a/drivers/media/rc/sunxi-cir.c
+++ b/drivers/media/rc/sunxi-cir.c
@@ -195,7 +195,6 @@ static int sunxi_ir_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
ir->base = devm_ioremap_resource(dev, res);
if (IS_ERR(ir->base)) {
-   dev_err(dev, "failed to map registers\n");
ret = PTR_ERR(ir->base);
goto exit_clkdisable_clk;
}
-- 
1.9.1





[PATCH] Arm: zx: remove redundant dev_err message

2019-06-18 Thread Ding Xiang
devm_ioremap_resource already contains error message, so remove
the redundant dev_err message

Signed-off-by: Ding Xiang 
---
 arch/arm/mach-zx/zx296702-pm-domain.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/arm/mach-zx/zx296702-pm-domain.c 
b/arch/arm/mach-zx/zx296702-pm-domain.c
index 7a08bf9d..ac44ea8 100644
--- a/arch/arm/mach-zx/zx296702-pm-domain.c
+++ b/arch/arm/mach-zx/zx296702-pm-domain.c
@@ -169,10 +169,8 @@ static int zx296702_pd_probe(struct platform_device *pdev)
}
 
pcubase = devm_ioremap_resource(>dev, res);
-   if (IS_ERR(pcubase)) {
-   dev_err(>dev, "ioremap fail.\n");
+   if (IS_ERR(pcubase))
return -EIO;
-   }
 
for (i = 0; i < ARRAY_SIZE(zx296702_pm_domains); ++i)
pm_genpd_init(zx296702_pm_domains[i], NULL, false);
-- 
1.9.1





[PATCH] sh/intc: Fix obsolete function

2019-05-29 Thread Ding Xiang
simple_strtoul is obsolete, use kstrtoul instead.

Signed-off-by: Ding Xiang 
---
 drivers/sh/intc/userimask.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/sh/intc/userimask.c b/drivers/sh/intc/userimask.c
index 87d69e7..d1d8e9b 100644
--- a/drivers/sh/intc/userimask.c
+++ b/drivers/sh/intc/userimask.c
@@ -33,7 +33,8 @@
 {
unsigned long level;
 
-   level = simple_strtoul(buf, NULL, 10);
+   if (kstrtoul(buf, 10, ))
+   return -EINVAL;
 
/*
 * Minimal acceptable IRQ levels are in the 2 - 16 range, but
-- 
1.9.1





[PATCH] mtd: afs: remove unneeded NULL check

2019-05-29 Thread Ding Xiang
NULL check before kfree is unneeded, so remove it.

Signed-off-by: Ding Xiang 
---
 drivers/mtd/parsers/afs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mtd/parsers/afs.c b/drivers/mtd/parsers/afs.c
index 0c73002..972b260 100644
--- a/drivers/mtd/parsers/afs.c
+++ b/drivers/mtd/parsers/afs.c
@@ -383,8 +383,7 @@ static int parse_afs_partitions(struct mtd_info *mtd,
 
 out_free_parts:
while (i >= 0) {
-   if (parts[i].name)
-   kfree(parts[i].name);
+   kfree(parts[i].name);
i--;
}
kfree(parts);
-- 
1.9.1





[PATCH] drivers/fmc: remove unneeded NULL check

2019-03-28 Thread Ding Xiang
The variable will check in debugfs_remove_recursive, so
the NULL check here is not needed

Signed-off-by: Ding Xiang 
---
 drivers/fmc/fmc-debug.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/fmc/fmc-debug.c b/drivers/fmc/fmc-debug.c
index 3293072..ab868a3 100644
--- a/drivers/fmc/fmc-debug.c
+++ b/drivers/fmc/fmc-debug.c
@@ -168,6 +168,5 @@ int fmc_debug_init(struct fmc_device *fmc)
 
 void fmc_debug_exit(struct fmc_device *fmc)
 {
-   if (fmc->dbg_dir)
-   debugfs_remove_recursive(fmc->dbg_dir);
+   debugfs_remove_recursive(fmc->dbg_dir);
 }
-- 
1.9.1





[PATCH] clk: davinci: cfgchip: use PTR_ERR_OR_ZERO in da8xx_cfgchip_register_div4p5

2019-03-15 Thread Ding Xiang
use PTR_ERR_OR_ZERO inetead of return code

Signed-off-by: Ding Xiang 
---
 drivers/clk/davinci/da8xx-cfgchip.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/clk/davinci/da8xx-cfgchip.c 
b/drivers/clk/davinci/da8xx-cfgchip.c
index d1bbee1..bdc5236 100644
--- a/drivers/clk/davinci/da8xx-cfgchip.c
+++ b/drivers/clk/davinci/da8xx-cfgchip.c
@@ -160,10 +160,8 @@ static int __init da8xx_cfgchip_register_div4p5(struct 
device *dev,
struct da8xx_cfgchip_gate_clk *gate;
 
gate = da8xx_cfgchip_gate_clk_register(dev, _div4p5ena_info, 
regmap);
-   if (IS_ERR(gate))
-   return PTR_ERR(gate);
 
-   return 0;
+   return PTR_ERR_OR_ZERO(gate);
 }
 
 static int __init
-- 
1.9.1





[tip:perf/core] perf bpf-loader: use PTR_ERR_OR_ZERO inetead of return code

2018-09-25 Thread tip-bot for Ding Xiang
Commit-ID:  e381d1c21eea186daed6834af444575e06841355
Gitweb: https://git.kernel.org/tip/e381d1c21eea186daed6834af444575e06841355
Author: Ding Xiang 
AuthorDate: Fri, 7 Sep 2018 09:34:42 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 19 Sep 2018 10:25:09 -0300

perf bpf-loader: use PTR_ERR_OR_ZERO inetead of return code

Use PTR_ERR_OR_ZERO() in bpf__setup_stdout() return code instead of open
coded equivalent.

Signed-off-by: Ding Xiang 
Cc: Alexander Shishkin 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1536284082-23466-2-git-send-email-dingxi...@cmss.chinamobile.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/bpf-loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 47aac41349a2..f9ae1a993806 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -1615,7 +1615,7 @@ struct perf_evsel *bpf__setup_output_event(struct 
perf_evlist *evlist, const cha
 int bpf__setup_stdout(struct perf_evlist *evlist)
 {
struct perf_evsel *evsel = bpf__setup_output_event(evlist, 
"__bpf_stdout__");
-   return IS_ERR(evsel) ? PTR_ERR(evsel) : 0;
+   return PTR_ERR_OR_ZERO(evsel);
 }
 
 #define ERRNO_OFFSET(e)((e) - __BPF_LOADER_ERRNO__START)


[tip:perf/core] perf bpf-loader: use PTR_ERR_OR_ZERO inetead of return code

2018-09-25 Thread tip-bot for Ding Xiang
Commit-ID:  e381d1c21eea186daed6834af444575e06841355
Gitweb: https://git.kernel.org/tip/e381d1c21eea186daed6834af444575e06841355
Author: Ding Xiang 
AuthorDate: Fri, 7 Sep 2018 09:34:42 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 19 Sep 2018 10:25:09 -0300

perf bpf-loader: use PTR_ERR_OR_ZERO inetead of return code

Use PTR_ERR_OR_ZERO() in bpf__setup_stdout() return code instead of open
coded equivalent.

Signed-off-by: Ding Xiang 
Cc: Alexander Shishkin 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1536284082-23466-2-git-send-email-dingxi...@cmss.chinamobile.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/bpf-loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 47aac41349a2..f9ae1a993806 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -1615,7 +1615,7 @@ struct perf_evsel *bpf__setup_output_event(struct 
perf_evlist *evlist, const cha
 int bpf__setup_stdout(struct perf_evlist *evlist)
 {
struct perf_evsel *evsel = bpf__setup_output_event(evlist, 
"__bpf_stdout__");
-   return IS_ERR(evsel) ? PTR_ERR(evsel) : 0;
+   return PTR_ERR_OR_ZERO(evsel);
 }
 
 #define ERRNO_OFFSET(e)((e) - __BPF_LOADER_ERRNO__START)


[tip:perf/core] tools include: Adopt PTR_ERR_OR_ZERO from the kernel err.h header

2018-09-25 Thread tip-bot for Ding Xiang
Commit-ID:  01ab2e91103b8c23dfedfeb799bc8b810d585bd0
Gitweb: https://git.kernel.org/tip/01ab2e91103b8c23dfedfeb799bc8b810d585bd0
Author: Ding Xiang 
AuthorDate: Fri, 7 Sep 2018 09:34:41 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 19 Sep 2018 10:25:08 -0300

tools include: Adopt PTR_ERR_OR_ZERO from the kernel err.h header

Add PTR_ERR_OR_ZERO, so that tools can use it, just like the kernel.

Signed-off-by: Ding Xiang 
Cc: Alexander Shishkin 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1536284082-23466-1-git-send-email-dingxi...@cmss.chinamobile.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/include/linux/err.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/tools/include/linux/err.h b/tools/include/linux/err.h
index 7a8b61ad44cb..094649667bae 100644
--- a/tools/include/linux/err.h
+++ b/tools/include/linux/err.h
@@ -52,4 +52,11 @@ static inline bool __must_check IS_ERR_OR_NULL(__force const 
void *ptr)
return unlikely(!ptr) || IS_ERR_VALUE((unsigned long)ptr);
 }
 
+static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
+{
+   if (IS_ERR(ptr))
+   return PTR_ERR(ptr);
+   else
+   return 0;
+}
 #endif /* _LINUX_ERR_H */


[tip:perf/core] tools include: Adopt PTR_ERR_OR_ZERO from the kernel err.h header

2018-09-25 Thread tip-bot for Ding Xiang
Commit-ID:  01ab2e91103b8c23dfedfeb799bc8b810d585bd0
Gitweb: https://git.kernel.org/tip/01ab2e91103b8c23dfedfeb799bc8b810d585bd0
Author: Ding Xiang 
AuthorDate: Fri, 7 Sep 2018 09:34:41 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 19 Sep 2018 10:25:08 -0300

tools include: Adopt PTR_ERR_OR_ZERO from the kernel err.h header

Add PTR_ERR_OR_ZERO, so that tools can use it, just like the kernel.

Signed-off-by: Ding Xiang 
Cc: Alexander Shishkin 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1536284082-23466-1-git-send-email-dingxi...@cmss.chinamobile.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/include/linux/err.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/tools/include/linux/err.h b/tools/include/linux/err.h
index 7a8b61ad44cb..094649667bae 100644
--- a/tools/include/linux/err.h
+++ b/tools/include/linux/err.h
@@ -52,4 +52,11 @@ static inline bool __must_check IS_ERR_OR_NULL(__force const 
void *ptr)
return unlikely(!ptr) || IS_ERR_VALUE((unsigned long)ptr);
 }
 
+static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
+{
+   if (IS_ERR(ptr))
+   return PTR_ERR(ptr);
+   else
+   return 0;
+}
 #endif /* _LINUX_ERR_H */


[PATCH 1/2] tools: include: Add PTR_ERR_OR_ZERO to err.h

2018-09-06 Thread Ding Xiang
Add PTR_ERR_OR_ZERO, and tools can use it.

Signed-off-by: Ding Xiang 
---
 tools/include/linux/err.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/tools/include/linux/err.h b/tools/include/linux/err.h
index 7a8b61a..0946496 100644
--- a/tools/include/linux/err.h
+++ b/tools/include/linux/err.h
@@ -52,4 +52,11 @@ static inline bool __must_check IS_ERR_OR_NULL(__force const 
void *ptr)
return unlikely(!ptr) || IS_ERR_VALUE((unsigned long)ptr);
 }
 
+static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
+{
+   if (IS_ERR(ptr))
+   return PTR_ERR(ptr);
+   else
+   return 0;
+}
 #endif /* _LINUX_ERR_H */
-- 
1.9.1





[PATCH 2/2] perf tools: use PTR_ERR_OR_ZERO inetead of return code

2018-09-06 Thread Ding Xiang
use PTR_ERR_OR_ZERO for bpf__setup_stdout return code,
it looks better.

Signed-off-by: Ding Xiang 
---
 tools/perf/util/bpf-loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 47aac41..f9ae1a9 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -1615,7 +1615,7 @@ struct perf_evsel *bpf__setup_output_event(struct 
perf_evlist *evlist, const cha
 int bpf__setup_stdout(struct perf_evlist *evlist)
 {
struct perf_evsel *evsel = bpf__setup_output_event(evlist, 
"__bpf_stdout__");
-   return IS_ERR(evsel) ? PTR_ERR(evsel) : 0;
+   return PTR_ERR_OR_ZERO(evsel);
 }
 
 #define ERRNO_OFFSET(e)((e) - __BPF_LOADER_ERRNO__START)
-- 
1.9.1





[PATCH 1/2] tools: include: Add PTR_ERR_OR_ZERO to err.h

2018-09-06 Thread Ding Xiang
Add PTR_ERR_OR_ZERO, and tools can use it.

Signed-off-by: Ding Xiang 
---
 tools/include/linux/err.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/tools/include/linux/err.h b/tools/include/linux/err.h
index 7a8b61a..0946496 100644
--- a/tools/include/linux/err.h
+++ b/tools/include/linux/err.h
@@ -52,4 +52,11 @@ static inline bool __must_check IS_ERR_OR_NULL(__force const 
void *ptr)
return unlikely(!ptr) || IS_ERR_VALUE((unsigned long)ptr);
 }
 
+static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
+{
+   if (IS_ERR(ptr))
+   return PTR_ERR(ptr);
+   else
+   return 0;
+}
 #endif /* _LINUX_ERR_H */
-- 
1.9.1





[PATCH 2/2] perf tools: use PTR_ERR_OR_ZERO inetead of return code

2018-09-06 Thread Ding Xiang
use PTR_ERR_OR_ZERO for bpf__setup_stdout return code,
it looks better.

Signed-off-by: Ding Xiang 
---
 tools/perf/util/bpf-loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 47aac41..f9ae1a9 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -1615,7 +1615,7 @@ struct perf_evsel *bpf__setup_output_event(struct 
perf_evlist *evlist, const cha
 int bpf__setup_stdout(struct perf_evlist *evlist)
 {
struct perf_evsel *evsel = bpf__setup_output_event(evlist, 
"__bpf_stdout__");
-   return IS_ERR(evsel) ? PTR_ERR(evsel) : 0;
+   return PTR_ERR_OR_ZERO(evsel);
 }
 
 #define ERRNO_OFFSET(e)((e) - __BPF_LOADER_ERRNO__START)
-- 
1.9.1





[PATCH v2] perf tools: use PTR_ERR_OR_ZERO inetead of return code

2018-09-06 Thread Ding Xiang
use PTR_ERR_OR_ZERO for bpf__setup_stdout return code

v2: add macro PTR_ERR_OR_ZERO to err.h

Signed-off-by: Ding Xiang 
---
 tools/include/linux/err.h| 7 +++
 tools/perf/util/bpf-loader.c | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/include/linux/err.h b/tools/include/linux/err.h
index 7a8b61a..0946496 100644
--- a/tools/include/linux/err.h
+++ b/tools/include/linux/err.h
@@ -52,4 +52,11 @@ static inline bool __must_check IS_ERR_OR_NULL(__force const 
void *ptr)
return unlikely(!ptr) || IS_ERR_VALUE((unsigned long)ptr);
 }
 
+static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
+{
+   if (IS_ERR(ptr))
+   return PTR_ERR(ptr);
+   else
+   return 0;
+}
 #endif /* _LINUX_ERR_H */
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 47aac41..f9ae1a9 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -1615,7 +1615,7 @@ struct perf_evsel *bpf__setup_output_event(struct 
perf_evlist *evlist, const cha
 int bpf__setup_stdout(struct perf_evlist *evlist)
 {
struct perf_evsel *evsel = bpf__setup_output_event(evlist, 
"__bpf_stdout__");
-   return IS_ERR(evsel) ? PTR_ERR(evsel) : 0;
+   return PTR_ERR_OR_ZERO(evsel);
 }
 
 #define ERRNO_OFFSET(e)((e) - __BPF_LOADER_ERRNO__START)
-- 
1.9.1





[PATCH v2] perf tools: use PTR_ERR_OR_ZERO inetead of return code

2018-09-06 Thread Ding Xiang
use PTR_ERR_OR_ZERO for bpf__setup_stdout return code

v2: add macro PTR_ERR_OR_ZERO to err.h

Signed-off-by: Ding Xiang 
---
 tools/include/linux/err.h| 7 +++
 tools/perf/util/bpf-loader.c | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/include/linux/err.h b/tools/include/linux/err.h
index 7a8b61a..0946496 100644
--- a/tools/include/linux/err.h
+++ b/tools/include/linux/err.h
@@ -52,4 +52,11 @@ static inline bool __must_check IS_ERR_OR_NULL(__force const 
void *ptr)
return unlikely(!ptr) || IS_ERR_VALUE((unsigned long)ptr);
 }
 
+static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
+{
+   if (IS_ERR(ptr))
+   return PTR_ERR(ptr);
+   else
+   return 0;
+}
 #endif /* _LINUX_ERR_H */
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 47aac41..f9ae1a9 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -1615,7 +1615,7 @@ struct perf_evsel *bpf__setup_output_event(struct 
perf_evlist *evlist, const cha
 int bpf__setup_stdout(struct perf_evlist *evlist)
 {
struct perf_evsel *evsel = bpf__setup_output_event(evlist, 
"__bpf_stdout__");
-   return IS_ERR(evsel) ? PTR_ERR(evsel) : 0;
+   return PTR_ERR_OR_ZERO(evsel);
 }
 
 #define ERRNO_OFFSET(e)((e) - __BPF_LOADER_ERRNO__START)
-- 
1.9.1





[PATCH] perf tools: use PTR_ERR_OR_ZERO inetead of return code

2018-09-06 Thread Ding Xiang
use PTR_ERR_OR_ZERO for bpf__setup_stdout return code

Signed-off-by: Ding Xiang 
---
 tools/perf/util/bpf-loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 47aac41..f9ae1a9 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -1615,7 +1615,7 @@ struct perf_evsel *bpf__setup_output_event(struct 
perf_evlist *evlist, const cha
 int bpf__setup_stdout(struct perf_evlist *evlist)
 {
struct perf_evsel *evsel = bpf__setup_output_event(evlist, 
"__bpf_stdout__");
-   return IS_ERR(evsel) ? PTR_ERR(evsel) : 0;
+   return PTR_ERR_OR_ZERO(evsel);
 }
 
 #define ERRNO_OFFSET(e)((e) - __BPF_LOADER_ERRNO__START)
-- 
1.9.1





[PATCH] perf tools: use PTR_ERR_OR_ZERO inetead of return code

2018-09-06 Thread Ding Xiang
use PTR_ERR_OR_ZERO for bpf__setup_stdout return code

Signed-off-by: Ding Xiang 
---
 tools/perf/util/bpf-loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 47aac41..f9ae1a9 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -1615,7 +1615,7 @@ struct perf_evsel *bpf__setup_output_event(struct 
perf_evlist *evlist, const cha
 int bpf__setup_stdout(struct perf_evlist *evlist)
 {
struct perf_evsel *evsel = bpf__setup_output_event(evlist, 
"__bpf_stdout__");
-   return IS_ERR(evsel) ? PTR_ERR(evsel) : 0;
+   return PTR_ERR_OR_ZERO(evsel);
 }
 
 #define ERRNO_OFFSET(e)((e) - __BPF_LOADER_ERRNO__START)
-- 
1.9.1





[PATCH] vme: remove unneeded kfree

2018-09-06 Thread Ding Xiang
put_device will call vme_dev_release to free vdev, kfree is
unnecessary here.

Signed-off-by: Ding Xiang 
---
 drivers/vme/vme.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 92500f6..520a5f9 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -1890,7 +1890,6 @@ static int __vme_register_driver_bus(struct vme_driver 
*drv,
 
 err_reg:
put_device(>dev);
-   kfree(vdev);
 err_devalloc:
list_for_each_entry_safe(vdev, tmp, >devices, drv_list) {
list_del(>drv_list);
-- 
1.9.1





[PATCH] vme: remove unneeded kfree

2018-09-06 Thread Ding Xiang
put_device will call vme_dev_release to free vdev, kfree is
unnecessary here.

Signed-off-by: Ding Xiang 
---
 drivers/vme/vme.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 92500f6..520a5f9 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -1890,7 +1890,6 @@ static int __vme_register_driver_bus(struct vme_driver 
*drv,
 
 err_reg:
put_device(>dev);
-   kfree(vdev);
 err_devalloc:
list_for_each_entry_safe(vdev, tmp, >devices, drv_list) {
list_del(>drv_list);
-- 
1.9.1





Re: [PATCH] scsi: zfcp: remove redundant put_device

2018-09-06 Thread Ding Xiang



On 9/6/2018 2:24 PM, Heiko Carstens wrote:

On Thu, Sep 06, 2018 at 02:16:27PM +0800, Ding Xiang wrote:

device_unregister will put device, do not need to do it one more time

Signed-off-by: Ding Xiang 
---
  drivers/s390/scsi/zfcp_unit.c | 2 --
  1 file changed, 2 deletions(-)

diff --git a/drivers/s390/scsi/zfcp_unit.c b/drivers/s390/scsi/zfcp_unit.c
index 1bf0a09..6b50084 100644
--- a/drivers/s390/scsi/zfcp_unit.c
+++ b/drivers/s390/scsi/zfcp_unit.c
@@ -249,8 +249,6 @@ int zfcp_unit_remove(struct zfcp_port *port, u64 fcp_lun)
scsi_device_put(sdev);
}

-   put_device(>dev);
-
device_unregister(>dev);

return 0;

I'm quite sure this change is wrong, since the put_device() here seems to
pair with the get_device() in _zfcp_unit_find(). So we would end up with a
memory leak.


Indeed,please ignore this patch.



Adding Steffen and Benjamin.








Re: [PATCH] scsi: zfcp: remove redundant put_device

2018-09-06 Thread Ding Xiang



On 9/6/2018 2:24 PM, Heiko Carstens wrote:

On Thu, Sep 06, 2018 at 02:16:27PM +0800, Ding Xiang wrote:

device_unregister will put device, do not need to do it one more time

Signed-off-by: Ding Xiang 
---
  drivers/s390/scsi/zfcp_unit.c | 2 --
  1 file changed, 2 deletions(-)

diff --git a/drivers/s390/scsi/zfcp_unit.c b/drivers/s390/scsi/zfcp_unit.c
index 1bf0a09..6b50084 100644
--- a/drivers/s390/scsi/zfcp_unit.c
+++ b/drivers/s390/scsi/zfcp_unit.c
@@ -249,8 +249,6 @@ int zfcp_unit_remove(struct zfcp_port *port, u64 fcp_lun)
scsi_device_put(sdev);
}

-   put_device(>dev);
-
device_unregister(>dev);

return 0;

I'm quite sure this change is wrong, since the put_device() here seems to
pair with the get_device() in _zfcp_unit_find(). So we would end up with a
memory leak.


Indeed,please ignore this patch.



Adding Steffen and Benjamin.








[PATCH] scsi: zfcp: remove redundant put_device

2018-09-06 Thread Ding Xiang
device_unregister will put device, do not need to do it one more time

Signed-off-by: Ding Xiang 
---
 drivers/s390/scsi/zfcp_unit.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/s390/scsi/zfcp_unit.c b/drivers/s390/scsi/zfcp_unit.c
index 1bf0a09..6b50084 100644
--- a/drivers/s390/scsi/zfcp_unit.c
+++ b/drivers/s390/scsi/zfcp_unit.c
@@ -249,8 +249,6 @@ int zfcp_unit_remove(struct zfcp_port *port, u64 fcp_lun)
scsi_device_put(sdev);
}
 
-   put_device(>dev);
-
device_unregister(>dev);
 
return 0;
-- 
1.9.1





[PATCH] scsi: zfcp: remove redundant put_device

2018-09-06 Thread Ding Xiang
device_unregister will put device, do not need to do it one more time

Signed-off-by: Ding Xiang 
---
 drivers/s390/scsi/zfcp_unit.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/s390/scsi/zfcp_unit.c b/drivers/s390/scsi/zfcp_unit.c
index 1bf0a09..6b50084 100644
--- a/drivers/s390/scsi/zfcp_unit.c
+++ b/drivers/s390/scsi/zfcp_unit.c
@@ -249,8 +249,6 @@ int zfcp_unit_remove(struct zfcp_port *port, u64 fcp_lun)
scsi_device_put(sdev);
}
 
-   put_device(>dev);
-
device_unregister(>dev);
 
return 0;
-- 
1.9.1





[PATCH] mips: txx9: fix iounmap related issue

2018-09-05 Thread Ding Xiang
if device_register return error, iounmap should be called, also iounmap
need to call before put_device.

Signed-off-by: Ding Xiang 
---
 arch/mips/txx9/generic/setup.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index f6d9182..70a1ab6 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -960,12 +960,11 @@ void __init txx9_sramc_init(struct resource *r)
goto exit_put;
err = sysfs_create_bin_file(>dev.kobj, >bindata_attr);
if (err) {
-   device_unregister(>dev);
iounmap(dev->base);
-   kfree(dev);
+   device_unregister(>dev);
}
return;
 exit_put:
+   iounmap(dev->base);
put_device(>dev);
-   return;
 }
-- 
1.9.1





[PATCH] mips: txx9: fix iounmap related issue

2018-09-05 Thread Ding Xiang
if device_register return error, iounmap should be called, also iounmap
need to call before put_device.

Signed-off-by: Ding Xiang 
---
 arch/mips/txx9/generic/setup.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index f6d9182..70a1ab6 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -960,12 +960,11 @@ void __init txx9_sramc_init(struct resource *r)
goto exit_put;
err = sysfs_create_bin_file(>dev.kobj, >bindata_attr);
if (err) {
-   device_unregister(>dev);
iounmap(dev->base);
-   kfree(dev);
+   device_unregister(>dev);
}
return;
 exit_put:
+   iounmap(dev->base);
put_device(>dev);
-   return;
 }
-- 
1.9.1





Re: [PATCH V2] mips: txx9: fix resource leak after register fail

2018-09-05 Thread Ding Xiang



On 9/5/2018 11:37 PM, Atsushi Nemoto wrote:

On Wed,  5 Sep 2018 19:22:19 +0800, Ding Xiang  
wrote:

the memory allocated and ioremap address need free after
device_register return error.

...

  exit_put:
put_device(>dev);
-   return;
+exit_free:
+   iounmap(dev->base);
+   kfree(dev);

This change will break exit_put error path.
I think kfree will be called from txx9_device_release by put_device.

Please refer James's comment on previous trial:
<https://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips=20180305221833.GJ4197%40saruman>


yes, put_device will call txx9_device_release and free txx9_sramc_dev, 
and kfree in  sysfs_create_bin_file() error handle


is also unneeded, I will send a new patch soon





Re: [PATCH V2] mips: txx9: fix resource leak after register fail

2018-09-05 Thread Ding Xiang



On 9/5/2018 11:37 PM, Atsushi Nemoto wrote:

On Wed,  5 Sep 2018 19:22:19 +0800, Ding Xiang  
wrote:

the memory allocated and ioremap address need free after
device_register return error.

...

  exit_put:
put_device(>dev);
-   return;
+exit_free:
+   iounmap(dev->base);
+   kfree(dev);

This change will break exit_put error path.
I think kfree will be called from txx9_device_release by put_device.

Please refer James's comment on previous trial:
<https://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips=20180305221833.GJ4197%40saruman>


yes, put_device will call txx9_device_release and free txx9_sramc_dev, 
and kfree in  sysfs_create_bin_file() error handle


is also unneeded, I will send a new patch soon





[PATCH V2] mips: txx9: fix resource leak after register fail

2018-09-05 Thread Ding Xiang
the memory allocated and ioremap address need free after
device_register return error.

v2: remove redundant "return"

Signed-off-by: Ding Xiang 
---
 arch/mips/txx9/generic/setup.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index f6d9182..e116a55 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -961,11 +961,12 @@ void __init txx9_sramc_init(struct resource *r)
err = sysfs_create_bin_file(>dev.kobj, >bindata_attr);
if (err) {
device_unregister(>dev);
-   iounmap(dev->base);
-   kfree(dev);
+   goto exit_free;
}
return;
 exit_put:
put_device(>dev);
-   return;
+exit_free:
+   iounmap(dev->base);
+   kfree(dev);
 }
-- 
1.9.1





[PATCH V2] mips: txx9: fix resource leak after register fail

2018-09-05 Thread Ding Xiang
the memory allocated and ioremap address need free after
device_register return error.

v2: remove redundant "return"

Signed-off-by: Ding Xiang 
---
 arch/mips/txx9/generic/setup.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index f6d9182..e116a55 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -961,11 +961,12 @@ void __init txx9_sramc_init(struct resource *r)
err = sysfs_create_bin_file(>dev.kobj, >bindata_attr);
if (err) {
device_unregister(>dev);
-   iounmap(dev->base);
-   kfree(dev);
+   goto exit_free;
}
return;
 exit_put:
put_device(>dev);
-   return;
+exit_free:
+   iounmap(dev->base);
+   kfree(dev);
 }
-- 
1.9.1





[PATCH] mips: txx9: fix resource leak after register fail

2018-09-05 Thread Ding Xiang
the memory allocated and ioremap address need free after
device_register return error.

Signed-off-by: Ding Xiang 
---
 arch/mips/txx9/generic/setup.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index f6d9182..7f4fd2b 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -961,11 +961,13 @@ void __init txx9_sramc_init(struct resource *r)
err = sysfs_create_bin_file(>dev.kobj, >bindata_attr);
if (err) {
device_unregister(>dev);
-   iounmap(dev->base);
-   kfree(dev);
+   goto exit_free;
}
return;
 exit_put:
put_device(>dev);
+exit_free:
+   iounmap(dev->base);
+   kfree(dev);
return;
 }
-- 
1.9.1





[PATCH] mips: txx9: fix resource leak after register fail

2018-09-05 Thread Ding Xiang
the memory allocated and ioremap address need free after
device_register return error.

Signed-off-by: Ding Xiang 
---
 arch/mips/txx9/generic/setup.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index f6d9182..7f4fd2b 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -961,11 +961,13 @@ void __init txx9_sramc_init(struct resource *r)
err = sysfs_create_bin_file(>dev.kobj, >bindata_attr);
if (err) {
device_unregister(>dev);
-   iounmap(dev->base);
-   kfree(dev);
+   goto exit_free;
}
return;
 exit_put:
put_device(>dev);
+exit_free:
+   iounmap(dev->base);
+   kfree(dev);
return;
 }
-- 
1.9.1





[PATCH] arch: sh: Replace dma_alloc_coherent/memset with dma_zalloc_coherent

2018-09-05 Thread Ding Xiang
use dma_zalloc_coherent instead of dma_alloc_coherent/memset

Signed-off-by: Ding Xiang 
---
 arch/sh/mm/consistent.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
index 792f361..aa4e450 100644
--- a/arch/sh/mm/consistent.c
+++ b/arch/sh/mm/consistent.c
@@ -52,14 +52,12 @@ int __init platform_resource_setup_memory(struct 
platform_device *pdev,
if (!memsize)
return 0;
 
-   buf = dma_alloc_coherent(>dev, memsize, _handle, GFP_KERNEL);
+   buf = dma_zalloc_coherent(>dev, memsize, _handle, GFP_KERNEL);
if (!buf) {
pr_warning("%s: unable to allocate memory\n", name);
return -ENOMEM;
}
 
-   memset(buf, 0, memsize);
-
r->flags = IORESOURCE_MEM;
r->start = dma_handle;
r->end = r->start + memsize - 1;
-- 
1.9.1





[PATCH] arch: sh: Replace dma_alloc_coherent/memset with dma_zalloc_coherent

2018-09-05 Thread Ding Xiang
use dma_zalloc_coherent instead of dma_alloc_coherent/memset

Signed-off-by: Ding Xiang 
---
 arch/sh/mm/consistent.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
index 792f361..aa4e450 100644
--- a/arch/sh/mm/consistent.c
+++ b/arch/sh/mm/consistent.c
@@ -52,14 +52,12 @@ int __init platform_resource_setup_memory(struct 
platform_device *pdev,
if (!memsize)
return 0;
 
-   buf = dma_alloc_coherent(>dev, memsize, _handle, GFP_KERNEL);
+   buf = dma_zalloc_coherent(>dev, memsize, _handle, GFP_KERNEL);
if (!buf) {
pr_warning("%s: unable to allocate memory\n", name);
return -ENOMEM;
}
 
-   memset(buf, 0, memsize);
-
r->flags = IORESOURCE_MEM;
r->start = dma_handle;
r->end = r->start + memsize - 1;
-- 
1.9.1





[PATCH] security: tomoyo: Fix obsolete function

2018-09-04 Thread Ding Xiang
simple_strtoul is obsolete, and use kstrtouint instead

Signed-off-by: Ding Xiang 
---
 security/tomoyo/common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c
index 03923a1..9b38f94 100644
--- a/security/tomoyo/common.c
+++ b/security/tomoyo/common.c
@@ -1660,7 +1660,8 @@ static void tomoyo_read_pid(struct tomoyo_io_buffer *head)
head->r.eof = true;
if (tomoyo_str_starts(, "global-pid "))
global_pid = true;
-   pid = (unsigned int) simple_strtoul(buf, NULL, 10);
+   if (kstrtouint(buf, 10, ))
+   return;
rcu_read_lock();
if (global_pid)
p = find_task_by_pid_ns(pid, _pid_ns);
-- 
1.9.1





[PATCH] security: tomoyo: Fix obsolete function

2018-09-04 Thread Ding Xiang
simple_strtoul is obsolete, and use kstrtouint instead

Signed-off-by: Ding Xiang 
---
 security/tomoyo/common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c
index 03923a1..9b38f94 100644
--- a/security/tomoyo/common.c
+++ b/security/tomoyo/common.c
@@ -1660,7 +1660,8 @@ static void tomoyo_read_pid(struct tomoyo_io_buffer *head)
head->r.eof = true;
if (tomoyo_str_starts(, "global-pid "))
global_pid = true;
-   pid = (unsigned int) simple_strtoul(buf, NULL, 10);
+   if (kstrtouint(buf, 10, ))
+   return;
rcu_read_lock();
if (global_pid)
p = find_task_by_pid_ns(pid, _pid_ns);
-- 
1.9.1





[PATCH] power: supply: ab8500_fg: fix obsolete function

2018-08-27 Thread Ding Xiang
simple_strtoul is obsolete, and use kstrtoint instead

Signed-off-by: Ding Xiang 
---
 drivers/power/supply/ab8500_fg.c | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c
index 02356f9..2bdadb5 100644
--- a/drivers/power/supply/ab8500_fg.c
+++ b/drivers/power/supply/ab8500_fg.c
@@ -2582,11 +2582,12 @@ static ssize_t ab8505_powercut_flagtime_write(struct 
device *dev,
  const char *buf, size_t count)
 {
int ret;
-   long unsigned reg_value;
+   int reg_value;
struct power_supply *psy = dev_get_drvdata(dev);
struct ab8500_fg *di = power_supply_get_drvdata(psy);
 
-   reg_value = simple_strtoul(buf, NULL, 10);
+   if (kstrtoint(buf, 10, _value))
+   goto fail;
 
if (reg_value > 0x7F) {
dev_err(dev, "Incorrect parameter, echo 0 (1.98s) - 127 
(15.625ms) for flagtime\n");
@@ -2636,7 +2637,9 @@ static ssize_t ab8505_powercut_maxtime_write(struct 
device *dev,
struct power_supply *psy = dev_get_drvdata(dev);
struct ab8500_fg *di = power_supply_get_drvdata(psy);
 
-   reg_value = simple_strtoul(buf, NULL, 10);
+   if (kstrtoint(buf, 10, _value))
+   goto fail;
+
if (reg_value > 0x7F) {
dev_err(dev, "Incorrect parameter, echo 0 (0.0s) - 127 (1.98s) 
for maxtime\n");
goto fail;
@@ -2684,7 +2687,9 @@ static ssize_t ab8505_powercut_restart_write(struct 
device *dev,
struct power_supply *psy = dev_get_drvdata(dev);
struct ab8500_fg *di = power_supply_get_drvdata(psy);
 
-   reg_value = simple_strtoul(buf, NULL, 10);
+   if (kstrtoint(buf, 10, _value))
+   goto fail;
+
if (reg_value > 0xF) {
dev_err(dev, "Incorrect parameter, echo 0 - 15 for number of 
restart\n");
goto fail;
@@ -2777,7 +2782,9 @@ static ssize_t ab8505_powercut_write(struct device *dev,
struct power_supply *psy = dev_get_drvdata(dev);
struct ab8500_fg *di = power_supply_get_drvdata(psy);
 
-   reg_value = simple_strtoul(buf, NULL, 10);
+   if (kstrtoint(buf, 10, _value))
+   goto fail;
+
if (reg_value > 0x1) {
dev_err(dev, "Incorrect parameter, echo 0/1 to disable/enable 
Pcut feature\n");
goto fail;
@@ -2849,7 +2856,9 @@ static ssize_t ab8505_powercut_debounce_write(struct 
device *dev,
struct power_supply *psy = dev_get_drvdata(dev);
struct ab8500_fg *di = power_supply_get_drvdata(psy);
 
-   reg_value = simple_strtoul(buf, NULL, 10);
+   if (kstrtoint(buf, 10, _value))
+   goto fail;
+
if (reg_value > 0x7) {
dev_err(dev, "Incorrect parameter, echo 0 to 7 for debounce 
setting\n");
goto fail;
-- 
1.8.3.1





[PATCH] power: supply: ab8500_fg: fix obsolete function

2018-08-27 Thread Ding Xiang
simple_strtoul is obsolete, and use kstrtoint instead

Signed-off-by: Ding Xiang 
---
 drivers/power/supply/ab8500_fg.c | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c
index 02356f9..2bdadb5 100644
--- a/drivers/power/supply/ab8500_fg.c
+++ b/drivers/power/supply/ab8500_fg.c
@@ -2582,11 +2582,12 @@ static ssize_t ab8505_powercut_flagtime_write(struct 
device *dev,
  const char *buf, size_t count)
 {
int ret;
-   long unsigned reg_value;
+   int reg_value;
struct power_supply *psy = dev_get_drvdata(dev);
struct ab8500_fg *di = power_supply_get_drvdata(psy);
 
-   reg_value = simple_strtoul(buf, NULL, 10);
+   if (kstrtoint(buf, 10, _value))
+   goto fail;
 
if (reg_value > 0x7F) {
dev_err(dev, "Incorrect parameter, echo 0 (1.98s) - 127 
(15.625ms) for flagtime\n");
@@ -2636,7 +2637,9 @@ static ssize_t ab8505_powercut_maxtime_write(struct 
device *dev,
struct power_supply *psy = dev_get_drvdata(dev);
struct ab8500_fg *di = power_supply_get_drvdata(psy);
 
-   reg_value = simple_strtoul(buf, NULL, 10);
+   if (kstrtoint(buf, 10, _value))
+   goto fail;
+
if (reg_value > 0x7F) {
dev_err(dev, "Incorrect parameter, echo 0 (0.0s) - 127 (1.98s) 
for maxtime\n");
goto fail;
@@ -2684,7 +2687,9 @@ static ssize_t ab8505_powercut_restart_write(struct 
device *dev,
struct power_supply *psy = dev_get_drvdata(dev);
struct ab8500_fg *di = power_supply_get_drvdata(psy);
 
-   reg_value = simple_strtoul(buf, NULL, 10);
+   if (kstrtoint(buf, 10, _value))
+   goto fail;
+
if (reg_value > 0xF) {
dev_err(dev, "Incorrect parameter, echo 0 - 15 for number of 
restart\n");
goto fail;
@@ -2777,7 +2782,9 @@ static ssize_t ab8505_powercut_write(struct device *dev,
struct power_supply *psy = dev_get_drvdata(dev);
struct ab8500_fg *di = power_supply_get_drvdata(psy);
 
-   reg_value = simple_strtoul(buf, NULL, 10);
+   if (kstrtoint(buf, 10, _value))
+   goto fail;
+
if (reg_value > 0x1) {
dev_err(dev, "Incorrect parameter, echo 0/1 to disable/enable 
Pcut feature\n");
goto fail;
@@ -2849,7 +2856,9 @@ static ssize_t ab8505_powercut_debounce_write(struct 
device *dev,
struct power_supply *psy = dev_get_drvdata(dev);
struct ab8500_fg *di = power_supply_get_drvdata(psy);
 
-   reg_value = simple_strtoul(buf, NULL, 10);
+   if (kstrtoint(buf, 10, _value))
+   goto fail;
+
if (reg_value > 0x7) {
dev_err(dev, "Incorrect parameter, echo 0 to 7 for debounce 
setting\n");
goto fail;
-- 
1.8.3.1





[PATCH V3] Bluetooth: bt3c_cs: Fix obsolete function

2018-08-26 Thread Ding Xiang
simple_strtol and simple_strtoul are obsolete, both place
use kstrtouint instead.

V2: fix error tmp += tn
V3: fix compile error

Signed-off-by: Ding Xiang 
---
 drivers/bluetooth/bt3c_cs.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 25b0cf9..5471383 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -448,7 +448,7 @@ static int bt3c_load_firmware(struct bt3c_info *info,
 {
char *ptr = (char *) firmware;
char b[9];
-   unsigned int iobase, tmp;
+   unsigned int iobase, tmp, tn;
unsigned long size, addr, fcs;
int i, err = 0;
 
@@ -490,7 +490,9 @@ static int bt3c_load_firmware(struct bt3c_info *info,
memset(b, 0, sizeof(b));
for (tmp = 0, i = 0; i < size; i++) {
memcpy(b, ptr + (i * 2) + 2, 2);
-   tmp += simple_strtol(b, NULL, 16);
+   if (kstrtouint(b, 16, ))
+   return -EINVAL;
+   tmp += tn;
}
 
if (((tmp + fcs) & 0xff) != 0xff) {
@@ -505,7 +507,8 @@ static int bt3c_load_firmware(struct bt3c_info *info,
memset(b, 0, sizeof(b));
for (i = 0; i < (size - 4) / 2; i++) {
memcpy(b, ptr + (i * 4) + 12, 4);
-   tmp = simple_strtoul(b, NULL, 16);
+   if (kstrtouint(b, 16, ))
+   return -EINVAL;
bt3c_put(iobase, tmp);
}
}
-- 
1.8.3.1





[PATCH V3] Bluetooth: bt3c_cs: Fix obsolete function

2018-08-26 Thread Ding Xiang
simple_strtol and simple_strtoul are obsolete, both place
use kstrtouint instead.

V2: fix error tmp += tn
V3: fix compile error

Signed-off-by: Ding Xiang 
---
 drivers/bluetooth/bt3c_cs.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 25b0cf9..5471383 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -448,7 +448,7 @@ static int bt3c_load_firmware(struct bt3c_info *info,
 {
char *ptr = (char *) firmware;
char b[9];
-   unsigned int iobase, tmp;
+   unsigned int iobase, tmp, tn;
unsigned long size, addr, fcs;
int i, err = 0;
 
@@ -490,7 +490,9 @@ static int bt3c_load_firmware(struct bt3c_info *info,
memset(b, 0, sizeof(b));
for (tmp = 0, i = 0; i < size; i++) {
memcpy(b, ptr + (i * 2) + 2, 2);
-   tmp += simple_strtol(b, NULL, 16);
+   if (kstrtouint(b, 16, ))
+   return -EINVAL;
+   tmp += tn;
}
 
if (((tmp + fcs) & 0xff) != 0xff) {
@@ -505,7 +507,8 @@ static int bt3c_load_firmware(struct bt3c_info *info,
memset(b, 0, sizeof(b));
for (i = 0; i < (size - 4) / 2; i++) {
memcpy(b, ptr + (i * 4) + 12, 4);
-   tmp = simple_strtoul(b, NULL, 16);
+   if (kstrtouint(b, 16, ))
+   return -EINVAL;
bt3c_put(iobase, tmp);
}
}
-- 
1.8.3.1





Re: [PATCH] staging: greybus: Fix null pointer dereference

2018-08-24 Thread Ding Xiang

Hi, Johan

    sorry, it's my fault.


On 8/24/2018 2:29 PM, Johan Hovold wrote:

On Fri, Aug 24, 2018 at 12:07:11AM -0400, Ding Xiang wrote:

If fw is null then fw->size will trigger null pointer dereference

Signed-off-by: Ding Xiang 
---
  drivers/staging/greybus/bootrom.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/bootrom.c 
b/drivers/staging/greybus/bootrom.c
index e85ffae..3af28a0 100644
--- a/drivers/staging/greybus/bootrom.c
+++ b/drivers/staging/greybus/bootrom.c
@@ -297,7 +297,7 @@ static int gb_bootrom_get_firmware(struct gb_operation *op)
  
  queue_work:

/* Refresh timeout */
-   if (!ret && (offset + size == fw->size))
+   if (!ret && fw && (offset + size == fw->size))
next_request = NEXT_REQ_READY_TO_BOOT;
else
next_request = NEXT_REQ_GET_FIRMWARE;

How could fw be NULL when ret is 0 here?

It may not be as obvious as one might have wished, but the current code
looks correct to me.

Johan








Re: [PATCH] staging: greybus: Fix null pointer dereference

2018-08-24 Thread Ding Xiang

Hi, Johan

    sorry, it's my fault.


On 8/24/2018 2:29 PM, Johan Hovold wrote:

On Fri, Aug 24, 2018 at 12:07:11AM -0400, Ding Xiang wrote:

If fw is null then fw->size will trigger null pointer dereference

Signed-off-by: Ding Xiang 
---
  drivers/staging/greybus/bootrom.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/bootrom.c 
b/drivers/staging/greybus/bootrom.c
index e85ffae..3af28a0 100644
--- a/drivers/staging/greybus/bootrom.c
+++ b/drivers/staging/greybus/bootrom.c
@@ -297,7 +297,7 @@ static int gb_bootrom_get_firmware(struct gb_operation *op)
  
  queue_work:

/* Refresh timeout */
-   if (!ret && (offset + size == fw->size))
+   if (!ret && fw && (offset + size == fw->size))
next_request = NEXT_REQ_READY_TO_BOOT;
else
next_request = NEXT_REQ_GET_FIRMWARE;

How could fw be NULL when ret is 0 here?

It may not be as obvious as one might have wished, but the current code
looks correct to me.

Johan








[PATCH V2] Bluetooth: bt3c_cs: Fix obsolete function

2018-08-24 Thread Ding Xiang
simple_strtol and simple_strtoul are obsolete, both place
use kstrtoul instead.

V2: fix error tmp += tn

Signed-off-by: Ding Xiang 
---
 drivers/bluetooth/bt3c_cs.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 25b0cf9..8f03774 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -449,7 +449,7 @@ static int bt3c_load_firmware(struct bt3c_info *info,
char *ptr = (char *) firmware;
char b[9];
unsigned int iobase, tmp;
-   unsigned long size, addr, fcs;
+   unsigned long size, addr, fcs, tn;
int i, err = 0;
 
iobase = info->p_dev->resource[0]->start;
@@ -490,7 +490,9 @@ static int bt3c_load_firmware(struct bt3c_info *info,
memset(b, 0, sizeof(b));
for (tmp = 0, i = 0; i < size; i++) {
memcpy(b, ptr + (i * 2) + 2, 2);
-   tmp += simple_strtol(b, NULL, 16);
+   if (kstrtoul(b, 16, ))
+   return -EINVAL;
+   tmp += tn;
}
 
if (((tmp + fcs) & 0xff) != 0xff) {
@@ -505,7 +507,8 @@ static int bt3c_load_firmware(struct bt3c_info *info,
memset(b, 0, sizeof(b));
for (i = 0; i < (size - 4) / 2; i++) {
memcpy(b, ptr + (i * 4) + 12, 4);
-   tmp = simple_strtoul(b, NULL, 16);
+   if (kstrtoul(b, 16, ))
+   return -EINVAL;
bt3c_put(iobase, tmp);
}
}
-- 
1.8.3.1





[PATCH V2] Bluetooth: bt3c_cs: Fix obsolete function

2018-08-24 Thread Ding Xiang
simple_strtol and simple_strtoul are obsolete, both place
use kstrtoul instead.

V2: fix error tmp += tn

Signed-off-by: Ding Xiang 
---
 drivers/bluetooth/bt3c_cs.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 25b0cf9..8f03774 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -449,7 +449,7 @@ static int bt3c_load_firmware(struct bt3c_info *info,
char *ptr = (char *) firmware;
char b[9];
unsigned int iobase, tmp;
-   unsigned long size, addr, fcs;
+   unsigned long size, addr, fcs, tn;
int i, err = 0;
 
iobase = info->p_dev->resource[0]->start;
@@ -490,7 +490,9 @@ static int bt3c_load_firmware(struct bt3c_info *info,
memset(b, 0, sizeof(b));
for (tmp = 0, i = 0; i < size; i++) {
memcpy(b, ptr + (i * 2) + 2, 2);
-   tmp += simple_strtol(b, NULL, 16);
+   if (kstrtoul(b, 16, ))
+   return -EINVAL;
+   tmp += tn;
}
 
if (((tmp + fcs) & 0xff) != 0xff) {
@@ -505,7 +507,8 @@ static int bt3c_load_firmware(struct bt3c_info *info,
memset(b, 0, sizeof(b));
for (i = 0; i < (size - 4) / 2; i++) {
memcpy(b, ptr + (i * 4) + 12, 4);
-   tmp = simple_strtoul(b, NULL, 16);
+   if (kstrtoul(b, 16, ))
+   return -EINVAL;
bt3c_put(iobase, tmp);
}
}
-- 
1.8.3.1





[PATCH] Bluetooth: bt3c_cs: Fix obsolete function

2018-08-24 Thread Ding Xiang
simple_strtol and simple_strtoul are obsolete, both place
use kstrtoul instead.

Signed-off-by: Ding Xiang 
---
 drivers/bluetooth/bt3c_cs.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 25b0cf9..5e4800d 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -449,7 +449,7 @@ static int bt3c_load_firmware(struct bt3c_info *info,
char *ptr = (char *) firmware;
char b[9];
unsigned int iobase, tmp;
-   unsigned long size, addr, fcs;
+   unsigned long size, addr, fcs, tn;
int i, err = 0;
 
iobase = info->p_dev->resource[0]->start;
@@ -490,7 +490,9 @@ static int bt3c_load_firmware(struct bt3c_info *info,
memset(b, 0, sizeof(b));
for (tmp = 0, i = 0; i < size; i++) {
memcpy(b, ptr + (i * 2) + 2, 2);
-   tmp += simple_strtol(b, NULL, 16);
+   if (kstrtoul(b, 16, ))
+   return -EINVAL;
+   tmp += tn;
}
 
if (((tmp + fcs) & 0xff) != 0xff) {
@@ -505,7 +507,9 @@ static int bt3c_load_firmware(struct bt3c_info *info,
memset(b, 0, sizeof(b));
for (i = 0; i < (size - 4) / 2; i++) {
memcpy(b, ptr + (i * 4) + 12, 4);
-   tmp = simple_strtoul(b, NULL, 16);
+   if (kstrtoul(b, 16, ))
+   return -EINVAL;
+   tmp += tn;
bt3c_put(iobase, tmp);
}
}
-- 
1.8.3.1





[PATCH] Bluetooth: bt3c_cs: Fix obsolete function

2018-08-24 Thread Ding Xiang
simple_strtol and simple_strtoul are obsolete, both place
use kstrtoul instead.

Signed-off-by: Ding Xiang 
---
 drivers/bluetooth/bt3c_cs.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 25b0cf9..5e4800d 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -449,7 +449,7 @@ static int bt3c_load_firmware(struct bt3c_info *info,
char *ptr = (char *) firmware;
char b[9];
unsigned int iobase, tmp;
-   unsigned long size, addr, fcs;
+   unsigned long size, addr, fcs, tn;
int i, err = 0;
 
iobase = info->p_dev->resource[0]->start;
@@ -490,7 +490,9 @@ static int bt3c_load_firmware(struct bt3c_info *info,
memset(b, 0, sizeof(b));
for (tmp = 0, i = 0; i < size; i++) {
memcpy(b, ptr + (i * 2) + 2, 2);
-   tmp += simple_strtol(b, NULL, 16);
+   if (kstrtoul(b, 16, ))
+   return -EINVAL;
+   tmp += tn;
}
 
if (((tmp + fcs) & 0xff) != 0xff) {
@@ -505,7 +507,9 @@ static int bt3c_load_firmware(struct bt3c_info *info,
memset(b, 0, sizeof(b));
for (i = 0; i < (size - 4) / 2; i++) {
memcpy(b, ptr + (i * 4) + 12, 4);
-   tmp = simple_strtoul(b, NULL, 16);
+   if (kstrtoul(b, 16, ))
+   return -EINVAL;
+   tmp += tn;
bt3c_put(iobase, tmp);
}
}
-- 
1.8.3.1





[PATCH] fs: ubifs: remove unneeded semicolon

2018-08-23 Thread Ding Xiang
delete redundant semicolon

Signed-off-by: Ding Xiang 
---
 fs/ubifs/sb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c
index bf17f58..d5c55e2 100644
--- a/fs/ubifs/sb.c
+++ b/fs/ubifs/sb.c
@@ -603,7 +603,7 @@ int ubifs_read_superblock(struct ubifs_info *c)
c->key_hash = key_test_hash;
c->key_hash_type = UBIFS_KEY_HASH_TEST;
break;
-   };
+   }
 
c->key_fmt = sup->key_fmt;
 
-- 
1.8.3.1





[PATCH] fs: ubifs: remove unneeded semicolon

2018-08-23 Thread Ding Xiang
delete redundant semicolon

Signed-off-by: Ding Xiang 
---
 fs/ubifs/sb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c
index bf17f58..d5c55e2 100644
--- a/fs/ubifs/sb.c
+++ b/fs/ubifs/sb.c
@@ -603,7 +603,7 @@ int ubifs_read_superblock(struct ubifs_info *c)
c->key_hash = key_test_hash;
c->key_hash_type = UBIFS_KEY_HASH_TEST;
break;
-   };
+   }
 
c->key_fmt = sup->key_fmt;
 
-- 
1.8.3.1





[PATCH] staging: greybus: Fix null pointer dereference

2018-08-23 Thread Ding Xiang
If fw is null then fw->size will trigger null pointer dereference

Signed-off-by: Ding Xiang 
---
 drivers/staging/greybus/bootrom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/bootrom.c 
b/drivers/staging/greybus/bootrom.c
index e85ffae..3af28a0 100644
--- a/drivers/staging/greybus/bootrom.c
+++ b/drivers/staging/greybus/bootrom.c
@@ -297,7 +297,7 @@ static int gb_bootrom_get_firmware(struct gb_operation *op)
 
 queue_work:
/* Refresh timeout */
-   if (!ret && (offset + size == fw->size))
+   if (!ret && fw && (offset + size == fw->size))
next_request = NEXT_REQ_READY_TO_BOOT;
else
next_request = NEXT_REQ_GET_FIRMWARE;
-- 
1.8.3.1





[PATCH] staging: greybus: Fix null pointer dereference

2018-08-23 Thread Ding Xiang
If fw is null then fw->size will trigger null pointer dereference

Signed-off-by: Ding Xiang 
---
 drivers/staging/greybus/bootrom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/bootrom.c 
b/drivers/staging/greybus/bootrom.c
index e85ffae..3af28a0 100644
--- a/drivers/staging/greybus/bootrom.c
+++ b/drivers/staging/greybus/bootrom.c
@@ -297,7 +297,7 @@ static int gb_bootrom_get_firmware(struct gb_operation *op)
 
 queue_work:
/* Refresh timeout */
-   if (!ret && (offset + size == fw->size))
+   if (!ret && fw && (offset + size == fw->size))
next_request = NEXT_REQ_READY_TO_BOOT;
else
next_request = NEXT_REQ_GET_FIRMWARE;
-- 
1.8.3.1





[PATCH] cpufreq: acpi: Remove some redundant code

2018-08-20 Thread Ding Xiang
For single statement blocks,braces are not necessary.
And "else" is not useful after return. So,remove these code.

Signed-off-by: Ding Xiang 
---
 drivers/cpufreq/acpi-cpufreq.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index b61f4ec..0751a0a 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -423,9 +423,8 @@ static int acpi_cpufreq_target(struct cpufreq_policy 
*policy,
unsigned int next_perf_state = 0; /* Index into perf table */
int result = 0;
 
-   if (unlikely(!data)) {
+   if (unlikely(!data))
return -ENODEV;
-   }
 
perf = to_perf_data(data);
next_perf_state = policy->freq_table[index].driver_data;
@@ -521,11 +520,10 @@ static unsigned int acpi_cpufreq_fast_switch(struct 
cpufreq_policy *policy,
}
perf->state = perf->state_count-1;
return freqn;
-   } else {
-   /* assume CPU is at P0... */
-   perf->state = 0;
-   return perf->states[0].core_frequency * 1000;
}
+   /* assume CPU is at P0... */
+   perf->state = 0;
+   return perf->states[0].core_frequency * 1000;
 }
 
 static void free_acpi_perf_data(void)
-- 
1.8.3.1





[PATCH] cpufreq: acpi: Remove some redundant code

2018-08-20 Thread Ding Xiang
For single statement blocks,braces are not necessary.
And "else" is not useful after return. So,remove these code.

Signed-off-by: Ding Xiang 
---
 drivers/cpufreq/acpi-cpufreq.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index b61f4ec..0751a0a 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -423,9 +423,8 @@ static int acpi_cpufreq_target(struct cpufreq_policy 
*policy,
unsigned int next_perf_state = 0; /* Index into perf table */
int result = 0;
 
-   if (unlikely(!data)) {
+   if (unlikely(!data))
return -ENODEV;
-   }
 
perf = to_perf_data(data);
next_perf_state = policy->freq_table[index].driver_data;
@@ -521,11 +520,10 @@ static unsigned int acpi_cpufreq_fast_switch(struct 
cpufreq_policy *policy,
}
perf->state = perf->state_count-1;
return freqn;
-   } else {
-   /* assume CPU is at P0... */
-   perf->state = 0;
-   return perf->states[0].core_frequency * 1000;
}
+   /* assume CPU is at P0... */
+   perf->state = 0;
+   return perf->states[0].core_frequency * 1000;
 }
 
 static void free_acpi_perf_data(void)
-- 
1.8.3.1





[PATCH V2] staging:xgifb:remove unused code

2016-08-23 Thread Ding Xiang
The variable data is assigned but never used in rest code.

Signed-off-by: Ding Xiang <dingxi...@huawei.com>
---
 drivers/staging/xgifb/vb_setmode.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/xgifb/vb_setmode.c 
b/drivers/staging/xgifb/vb_setmode.c
index 50c8ea4..71bb9ca 100644
--- a/drivers/staging/xgifb/vb_setmode.c
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -727,7 +727,6 @@ static void XGI_SetCRT1DE(unsigned short ModeIdIndex,
tempax |= 0x40;
 
xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax);
-   data = xgifb_reg_get(pVBInfo->P3d4, 0x07);
tempax = 0;
 
if (tempbx & 0x04)
-- 
1.7.1



[PATCH V2] staging:xgifb:remove unused code

2016-08-23 Thread Ding Xiang
The variable data is assigned but never used in rest code.

Signed-off-by: Ding Xiang 
---
 drivers/staging/xgifb/vb_setmode.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/xgifb/vb_setmode.c 
b/drivers/staging/xgifb/vb_setmode.c
index 50c8ea4..71bb9ca 100644
--- a/drivers/staging/xgifb/vb_setmode.c
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -727,7 +727,6 @@ static void XGI_SetCRT1DE(unsigned short ModeIdIndex,
tempax |= 0x40;
 
xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax);
-   data = xgifb_reg_get(pVBInfo->P3d4, 0x07);
tempax = 0;
 
if (tempbx & 0x04)
-- 
1.7.1



[PATCH resend] staging:xgifb:remove unused code

2016-08-23 Thread Ding Xiang
The variable data is assigned but never used in rest code.

Signed-off-by: Ding Xiang <dingxi...@huawei.com>
---
 drivers/staging/xgifb/vb_setmode.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/xgifb/vb_setmode.c 
b/drivers/staging/xgifb/vb_setmode.c
index 50c8ea4..71bb9ca 100644
--- a/drivers/staging/xgifb/vb_setmode.c
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -727,7 +727,6 @@ static void XGI_SetCRT1DE(unsigned short ModeIdIndex,
tempax |= 0x40;
 
xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax);
-   data = xgifb_reg_get(pVBInfo->P3d4, 0x07);
tempax = 0;
 
if (tempbx & 0x04)
-- 
1.7.1



[PATCH resend] staging:xgifb:remove unused code

2016-08-23 Thread Ding Xiang
The variable data is assigned but never used in rest code.

Signed-off-by: Ding Xiang 
---
 drivers/staging/xgifb/vb_setmode.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/xgifb/vb_setmode.c 
b/drivers/staging/xgifb/vb_setmode.c
index 50c8ea4..71bb9ca 100644
--- a/drivers/staging/xgifb/vb_setmode.c
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -727,7 +727,6 @@ static void XGI_SetCRT1DE(unsigned short ModeIdIndex,
tempax |= 0x40;
 
xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax);
-   data = xgifb_reg_get(pVBInfo->P3d4, 0x07);
tempax = 0;
 
if (tempbx & 0x04)
-- 
1.7.1