Re: [PATCH] staging: lustre: fix return type of lo_release.

2013-05-16 Thread Cyril Roelandt

On 05/16/2013 09:01 PM, Greg KH wrote:

On Thu, May 16, 2013 at 06:06:20PM +0200, Cyril Roelandt wrote:

The return type of block_device_operations.release() changed to void in commit
db2a144b.


Interesting, how did you test build this patch, given that the driver
doesn't currently build at all?  :)



Well, the patch seemed simple enough to be sent anyway :)

Cyril Roelandt.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: lustre: fix return type of lo_release.

2013-05-16 Thread Cyril Roelandt
The return type of block_device_operations.release() changed to void in commit
db2a144b.

Found with the following Coccinelle patch:

@has_release_func@
identifier i;
identifier release_func;
@@
struct block_device_operations i = {
 .release = release_func
};

@depends on has_release_func@
identifier has_release_func.release_func;
@@
- int
+ void
release_func(...) {
...
- return ...;
}


Signed-off-by: Cyril Roelandt 
---
 drivers/staging/lustre/lustre/llite/lloop.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/lloop.c 
b/drivers/staging/lustre/lustre/llite/lloop.c
index b72f257..9d4c17e 100644
--- a/drivers/staging/lustre/lustre/llite/lloop.c
+++ b/drivers/staging/lustre/lustre/llite/lloop.c
@@ -596,15 +596,13 @@ static int lo_open(struct block_device *bdev, fmode_t 
mode)
return 0;
 }
 
-static int lo_release(struct gendisk *disk, fmode_t mode)
+static void lo_release(struct gendisk *disk, fmode_t mode)
 {
struct lloop_device *lo = disk->private_data;
 
mutex_lock(>lo_ctl_mutex);
--lo->lo_refcnt;
mutex_unlock(>lo_ctl_mutex);
-
-   return 0;
 }
 
 /* lloop device node's ioctl function. */
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: lustre: fix return type of lo_release.

2013-05-16 Thread Cyril Roelandt
The return type of block_device_operations.release() changed to void in commit
db2a144b.

Found with the following Coccinelle patch:
smpl
@has_release_func@
identifier i;
identifier release_func;
@@
struct block_device_operations i = {
 .release = release_func
};

@depends on has_release_func@
identifier has_release_func.release_func;
@@
- int
+ void
release_func(...) {
...
- return ...;
}
/smpl

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/staging/lustre/lustre/llite/lloop.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/lloop.c 
b/drivers/staging/lustre/lustre/llite/lloop.c
index b72f257..9d4c17e 100644
--- a/drivers/staging/lustre/lustre/llite/lloop.c
+++ b/drivers/staging/lustre/lustre/llite/lloop.c
@@ -596,15 +596,13 @@ static int lo_open(struct block_device *bdev, fmode_t 
mode)
return 0;
 }
 
-static int lo_release(struct gendisk *disk, fmode_t mode)
+static void lo_release(struct gendisk *disk, fmode_t mode)
 {
struct lloop_device *lo = disk-private_data;
 
mutex_lock(lo-lo_ctl_mutex);
--lo-lo_refcnt;
mutex_unlock(lo-lo_ctl_mutex);
-
-   return 0;
 }
 
 /* lloop device node's ioctl function. */
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] staging: lustre: fix return type of lo_release.

2013-05-16 Thread Cyril Roelandt

On 05/16/2013 09:01 PM, Greg KH wrote:

On Thu, May 16, 2013 at 06:06:20PM +0200, Cyril Roelandt wrote:

The return type of block_device_operations.release() changed to void in commit
db2a144b.


Interesting, how did you test build this patch, given that the driver
doesn't currently build at all?  :)



Well, the patch seemed simple enough to be sent anyway :)

Cyril Roelandt.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] net: ethernet: ti: remove redundant NULL check.

2013-02-12 Thread Cyril Roelandt

On 02/12/2013 11:06 PM, David Miller wrote:

From: Cyril Roelandt
Date: Tue, 12 Feb 2013 22:54:46 +0100


cpdma_chan_destroy() on a NULL pointer is a no-op, so the NULL check in
cpdma_ctlr_destroy() can safely be removed.

Signed-off-by: Cyril Roelandt

  ...

@@ -450,8 +450,7 @@ int cpdma_ctlr_destroy(struct cpdma_ctlr *ctlr)
cpdma_ctlr_stop(ctlr);

for (i = 0; i<  ARRAY_SIZE(ctlr->channels); i++) {
-   if (ctlr->channels[i])
-   cpdma_chan_destroy(ctlr->channels[i]);
+   cpdma_chan_destroy(ctlr->channels[i]);
}


SInce this is now a single statement basic block, remove the
surrounding braces.


Ok, I resent, though I forgot to add "v2".

Regards,
Cyril Roelandt.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] net: ethernet: ti: remove redundant NULL check.

2013-02-12 Thread Cyril Roelandt
cpdma_chan_destroy() on a NULL pointer is a no-op, so the NULL check in
cpdma_ctlr_destroy() can safely be removed.

Signed-off-by: Cyril Roelandt 
---
 drivers/net/ethernet/ti/davinci_cpdma.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c 
b/drivers/net/ethernet/ti/davinci_cpdma.c
index f862918..1c4b0aa 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -449,10 +449,8 @@ int cpdma_ctlr_destroy(struct cpdma_ctlr *ctlr)
if (ctlr->state != CPDMA_STATE_IDLE)
cpdma_ctlr_stop(ctlr);
 
-   for (i = 0; i < ARRAY_SIZE(ctlr->channels); i++) {
-   if (ctlr->channels[i])
-   cpdma_chan_destroy(ctlr->channels[i]);
-   }
+   for (i = 0; i < ARRAY_SIZE(ctlr->channels); i++)
+   cpdma_chan_destroy(ctlr->channels[i]);
 
cpdma_desc_pool_destroy(ctlr->pool);
spin_unlock_irqrestore(>lock, flags);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] net: ethernet: ti: remove redundant NULL check.

2013-02-12 Thread Cyril Roelandt
cpdma_chan_destroy() on a NULL pointer is a no-op, so the NULL check in
cpdma_ctlr_destroy() can safely be removed.

Signed-off-by: Cyril Roelandt 
---
 drivers/net/ethernet/ti/davinci_cpdma.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c 
b/drivers/net/ethernet/ti/davinci_cpdma.c
index f862918..aba787b 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -450,8 +450,7 @@ int cpdma_ctlr_destroy(struct cpdma_ctlr *ctlr)
cpdma_ctlr_stop(ctlr);
 
for (i = 0; i < ARRAY_SIZE(ctlr->channels); i++) {
-   if (ctlr->channels[i])
-   cpdma_chan_destroy(ctlr->channels[i]);
+   cpdma_chan_destroy(ctlr->channels[i]);
}
 
cpdma_desc_pool_destroy(ctlr->pool);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] net: ethernet: ti: remove redundant NULL check.

2013-02-12 Thread Cyril Roelandt
cpdma_chan_destroy() on a NULL pointer is a no-op, so the NULL check in
cpdma_ctlr_destroy() can safely be removed.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/net/ethernet/ti/davinci_cpdma.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c 
b/drivers/net/ethernet/ti/davinci_cpdma.c
index f862918..aba787b 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -450,8 +450,7 @@ int cpdma_ctlr_destroy(struct cpdma_ctlr *ctlr)
cpdma_ctlr_stop(ctlr);
 
for (i = 0; i  ARRAY_SIZE(ctlr-channels); i++) {
-   if (ctlr-channels[i])
-   cpdma_chan_destroy(ctlr-channels[i]);
+   cpdma_chan_destroy(ctlr-channels[i]);
}
 
cpdma_desc_pool_destroy(ctlr-pool);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] net: ethernet: ti: remove redundant NULL check.

2013-02-12 Thread Cyril Roelandt
cpdma_chan_destroy() on a NULL pointer is a no-op, so the NULL check in
cpdma_ctlr_destroy() can safely be removed.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/net/ethernet/ti/davinci_cpdma.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c 
b/drivers/net/ethernet/ti/davinci_cpdma.c
index f862918..1c4b0aa 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -449,10 +449,8 @@ int cpdma_ctlr_destroy(struct cpdma_ctlr *ctlr)
if (ctlr-state != CPDMA_STATE_IDLE)
cpdma_ctlr_stop(ctlr);
 
-   for (i = 0; i  ARRAY_SIZE(ctlr-channels); i++) {
-   if (ctlr-channels[i])
-   cpdma_chan_destroy(ctlr-channels[i]);
-   }
+   for (i = 0; i  ARRAY_SIZE(ctlr-channels); i++)
+   cpdma_chan_destroy(ctlr-channels[i]);
 
cpdma_desc_pool_destroy(ctlr-pool);
spin_unlock_irqrestore(ctlr-lock, flags);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] net: ethernet: ti: remove redundant NULL check.

2013-02-12 Thread Cyril Roelandt

On 02/12/2013 11:06 PM, David Miller wrote:

From: Cyril Roelandttipec...@gmail.com
Date: Tue, 12 Feb 2013 22:54:46 +0100


cpdma_chan_destroy() on a NULL pointer is a no-op, so the NULL check in
cpdma_ctlr_destroy() can safely be removed.

Signed-off-by: Cyril Roelandttipec...@gmail.com

  ...

@@ -450,8 +450,7 @@ int cpdma_ctlr_destroy(struct cpdma_ctlr *ctlr)
cpdma_ctlr_stop(ctlr);

for (i = 0; i  ARRAY_SIZE(ctlr-channels); i++) {
-   if (ctlr-channels[i])
-   cpdma_chan_destroy(ctlr-channels[i]);
+   cpdma_chan_destroy(ctlr-channels[i]);
}


SInce this is now a single statement basic block, remove the
surrounding braces.


Ok, I resent, though I forgot to add v2.

Regards,
Cyril Roelandt.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/5] staging: dgrp: remove redundant NULL check before unregister_dgrp_device().

2013-02-11 Thread Cyril Roelandt

unregister_dgrp_device on a NULL pointer is a no-op, so the NULL checks in
dgrp_remove_nd() can be removed.

Signed-off-by: Cyril Roelandt 
---
 drivers/staging/dgrp/dgrp_specproc.c |9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/dgrp/dgrp_specproc.c 
b/drivers/staging/dgrp/dgrp_specproc.c
index dfdaede..13c7ccf 100644
--- a/drivers/staging/dgrp/dgrp_specproc.c
+++ b/drivers/staging/dgrp/dgrp_specproc.c
@@ -777,14 +777,11 @@ static int dgrp_remove_nd(struct nd_struct *nd)
dgrp_remove_node_class_sysfs_files(nd);
}
 
-   if (nd->nd_mon_de)
-   unregister_dgrp_device(nd->nd_mon_de);
+   unregister_dgrp_device(nd->nd_mon_de);
 
-   if (nd->nd_ports_de)
-   unregister_dgrp_device(nd->nd_ports_de);
+   unregister_dgrp_device(nd->nd_ports_de);
 
-   if (nd->nd_dpa_de)
-   unregister_dgrp_device(nd->nd_dpa_de);
+   unregister_dgrp_device(nd->nd_dpa_de);
 
dgrp_tty_uninit(nd);
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/5] xen: remove redundant NULL check before unregister_and_remove_pcpu().

2013-02-11 Thread Cyril Roelandt
unregister_and_remove_pcpu on a NULL pointer is a no-op, so the NULL check in
sync_pcpu can be removed.

Signed-off-by: Cyril Roelandt 
---
 drivers/xen/pcpu.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/xen/pcpu.c b/drivers/xen/pcpu.c
index 067fcfa..5a27a45 100644
--- a/drivers/xen/pcpu.c
+++ b/drivers/xen/pcpu.c
@@ -278,8 +278,7 @@ static int sync_pcpu(uint32_t cpu, uint32_t *max_cpu)
 * Only those at cpu present map has its sys interface.
 */
if (info->flags & XEN_PCPU_FLAGS_INVALID) {
-   if (pcpu)
-   unregister_and_remove_pcpu(pcpu);
+   unregister_and_remove_pcpu(pcpu);
return 0;
}
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/5] iommu: remove redundant NULL check before dma_ops_domain_free().

2013-02-11 Thread Cyril Roelandt
dma_ops_domain_free on a NULL pointer is a no-op, so the NULL check in
amd_iommu_init_dma_ops() can be removed.

Signed-off-by: Cyril Roelandt 
---
 drivers/iommu/amd_iommu.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index d33eaaf..98f555d 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -3187,8 +3187,7 @@ int __init amd_iommu_init_dma_ops(void)
 free_domains:
 
for_each_iommu(iommu) {
-   if (iommu->default_dom)
-   dma_ops_domain_free(iommu->default_dom);
+   dma_ops_domain_free(iommu->default_dom);
}
 
return ret;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/5] staging: tidspbridge: remove redundant NULL check before delete_msg_mgr().

2013-02-11 Thread Cyril Roelandt

delete_msg_mgr on a NULL pointer is a no-op, so the NULL check in
bridge_msg_delete can be removed.

Signed-off-by: Cyril Roelandt 
---
 drivers/staging/tidspbridge/core/msg_sm.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/tidspbridge/core/msg_sm.c 
b/drivers/staging/tidspbridge/core/msg_sm.c
index ce9557e..7b517eb 100644
--- a/drivers/staging/tidspbridge/core/msg_sm.c
+++ b/drivers/staging/tidspbridge/core/msg_sm.c
@@ -198,8 +198,7 @@ out_err:
  */
 void bridge_msg_delete(struct msg_mgr *hmsg_mgr)
 {
-   if (hmsg_mgr)
-   delete_msg_mgr(hmsg_mgr);
+   delete_msg_mgr(hmsg_mgr);
 }
 
 /*
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/5] Remove redundant NULL checks.

2013-02-11 Thread Cyril Roelandt
Remove redundant NULL checks before calls to functions that are equivalent to a
no-op when run on a NULL pointer.

These patches were generated by the following semantic patch, and manually
reviewed:


@r@
identifier noop_func;
identifier param;
type T;
@@
noop_func (T *param) {
...
if (!param) return;
...
}

@@
identifier r.noop_func;
expression E;
statement S;
@@
(
- if (E) noop_func(E);
+ noop_func(E);
|
- if (E) { noop_func(E); E = NULL; }
+ noop_func(E);
+ E = NULL;
)


Regards,
Cyril Roelandt
---

Cyril Roelandt (5):
  radeon: Remove redundant NULL check before radeon_i2c_destroy().
  iommu: remove redundant NULL check before dma_ops_domain_free().
  staging: dgrp: remove redundant NULL check before
unregister_dgrp_device().
  staging: tidspbridge: remove redundant NULL check before
delete_msg_mgr().
  xen: remove redundant NULL check before unregister_and_remove_pcpu().

 drivers/gpu/drm/radeon/radeon_i2c.c   |6 ++
 drivers/iommu/amd_iommu.c |3 +--
 drivers/staging/dgrp/dgrp_specproc.c  |9 +++--
 drivers/staging/tidspbridge/core/msg_sm.c |3 +--
 drivers/xen/pcpu.c|3 +--
 5 files changed, 8 insertions(+), 16 deletions(-)

-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/5] radeon: Remove redundant NULL check before radeon_i2c_destroy().

2013-02-11 Thread Cyril Roelandt
radeon_i2c_destroy on a NULL pointer is a no-op.

Signed-off-by: Cyril Roelandt 
---
 drivers/gpu/drm/radeon/radeon_i2c.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c 
b/drivers/gpu/drm/radeon/radeon_i2c.c
index fc60b74..850df44 100644
--- a/drivers/gpu/drm/radeon/radeon_i2c.c
+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
@@ -1032,10 +1032,8 @@ void radeon_i2c_fini(struct radeon_device *rdev)
int i;
 
for (i = 0; i < RADEON_MAX_I2C_BUS; i++) {
-   if (rdev->i2c_bus[i]) {
-   radeon_i2c_destroy(rdev->i2c_bus[i]);
-   rdev->i2c_bus[i] = NULL;
-   }
+   radeon_i2c_destroy(rdev->i2c_bus[i]);
+   rdev->i2c_bus[i] = NULL;
}
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/5] Remove redundant NULL checks.

2013-02-11 Thread Cyril Roelandt
Remove redundant NULL checks before calls to functions that are equivalent to a
no-op when run on a NULL pointer.

These patches were generated by the following semantic patch, and manually
reviewed:

smpl
@r@
identifier noop_func;
identifier param;
type T;
@@
noop_func (T *param) {
...
if (!param) return;
...
}

@@
identifier r.noop_func;
expression E;
statement S;
@@
(
- if (E) noop_func(E);
+ noop_func(E);
|
- if (E) { noop_func(E); E = NULL; }
+ noop_func(E);
+ E = NULL;
)
/smpl

Regards,
Cyril Roelandt
---

Cyril Roelandt (5):
  radeon: Remove redundant NULL check before radeon_i2c_destroy().
  iommu: remove redundant NULL check before dma_ops_domain_free().
  staging: dgrp: remove redundant NULL check before
unregister_dgrp_device().
  staging: tidspbridge: remove redundant NULL check before
delete_msg_mgr().
  xen: remove redundant NULL check before unregister_and_remove_pcpu().

 drivers/gpu/drm/radeon/radeon_i2c.c   |6 ++
 drivers/iommu/amd_iommu.c |3 +--
 drivers/staging/dgrp/dgrp_specproc.c  |9 +++--
 drivers/staging/tidspbridge/core/msg_sm.c |3 +--
 drivers/xen/pcpu.c|3 +--
 5 files changed, 8 insertions(+), 16 deletions(-)

-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/5] radeon: Remove redundant NULL check before radeon_i2c_destroy().

2013-02-11 Thread Cyril Roelandt
radeon_i2c_destroy on a NULL pointer is a no-op.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/gpu/drm/radeon/radeon_i2c.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c 
b/drivers/gpu/drm/radeon/radeon_i2c.c
index fc60b74..850df44 100644
--- a/drivers/gpu/drm/radeon/radeon_i2c.c
+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
@@ -1032,10 +1032,8 @@ void radeon_i2c_fini(struct radeon_device *rdev)
int i;
 
for (i = 0; i  RADEON_MAX_I2C_BUS; i++) {
-   if (rdev-i2c_bus[i]) {
-   radeon_i2c_destroy(rdev-i2c_bus[i]);
-   rdev-i2c_bus[i] = NULL;
-   }
+   radeon_i2c_destroy(rdev-i2c_bus[i]);
+   rdev-i2c_bus[i] = NULL;
}
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/5] iommu: remove redundant NULL check before dma_ops_domain_free().

2013-02-11 Thread Cyril Roelandt
dma_ops_domain_free on a NULL pointer is a no-op, so the NULL check in
amd_iommu_init_dma_ops() can be removed.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/iommu/amd_iommu.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index d33eaaf..98f555d 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -3187,8 +3187,7 @@ int __init amd_iommu_init_dma_ops(void)
 free_domains:
 
for_each_iommu(iommu) {
-   if (iommu-default_dom)
-   dma_ops_domain_free(iommu-default_dom);
+   dma_ops_domain_free(iommu-default_dom);
}
 
return ret;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/5] staging: tidspbridge: remove redundant NULL check before delete_msg_mgr().

2013-02-11 Thread Cyril Roelandt

delete_msg_mgr on a NULL pointer is a no-op, so the NULL check in
bridge_msg_delete can be removed.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/staging/tidspbridge/core/msg_sm.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/tidspbridge/core/msg_sm.c 
b/drivers/staging/tidspbridge/core/msg_sm.c
index ce9557e..7b517eb 100644
--- a/drivers/staging/tidspbridge/core/msg_sm.c
+++ b/drivers/staging/tidspbridge/core/msg_sm.c
@@ -198,8 +198,7 @@ out_err:
  */
 void bridge_msg_delete(struct msg_mgr *hmsg_mgr)
 {
-   if (hmsg_mgr)
-   delete_msg_mgr(hmsg_mgr);
+   delete_msg_mgr(hmsg_mgr);
 }
 
 /*
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/5] xen: remove redundant NULL check before unregister_and_remove_pcpu().

2013-02-11 Thread Cyril Roelandt
unregister_and_remove_pcpu on a NULL pointer is a no-op, so the NULL check in
sync_pcpu can be removed.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/xen/pcpu.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/xen/pcpu.c b/drivers/xen/pcpu.c
index 067fcfa..5a27a45 100644
--- a/drivers/xen/pcpu.c
+++ b/drivers/xen/pcpu.c
@@ -278,8 +278,7 @@ static int sync_pcpu(uint32_t cpu, uint32_t *max_cpu)
 * Only those at cpu present map has its sys interface.
 */
if (info-flags  XEN_PCPU_FLAGS_INVALID) {
-   if (pcpu)
-   unregister_and_remove_pcpu(pcpu);
+   unregister_and_remove_pcpu(pcpu);
return 0;
}
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/5] staging: dgrp: remove redundant NULL check before unregister_dgrp_device().

2013-02-11 Thread Cyril Roelandt

unregister_dgrp_device on a NULL pointer is a no-op, so the NULL checks in
dgrp_remove_nd() can be removed.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/staging/dgrp/dgrp_specproc.c |9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/dgrp/dgrp_specproc.c 
b/drivers/staging/dgrp/dgrp_specproc.c
index dfdaede..13c7ccf 100644
--- a/drivers/staging/dgrp/dgrp_specproc.c
+++ b/drivers/staging/dgrp/dgrp_specproc.c
@@ -777,14 +777,11 @@ static int dgrp_remove_nd(struct nd_struct *nd)
dgrp_remove_node_class_sysfs_files(nd);
}
 
-   if (nd-nd_mon_de)
-   unregister_dgrp_device(nd-nd_mon_de);
+   unregister_dgrp_device(nd-nd_mon_de);
 
-   if (nd-nd_ports_de)
-   unregister_dgrp_device(nd-nd_ports_de);
+   unregister_dgrp_device(nd-nd_ports_de);
 
-   if (nd-nd_dpa_de)
-   unregister_dgrp_device(nd-nd_dpa_de);
+   unregister_dgrp_device(nd-nd_dpa_de);
 
dgrp_tty_uninit(nd);
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mwifiex: avoid out of bounds access in mwifiex_get_common_rates.

2013-01-27 Thread Cyril Roelandt
Check that the array indexes are in-bounds before accessing the rate2 and tmp
arrays.

Found with the following semantic patch:


@@
identifier t;
identifier idx;
expression E;
statement S;
@@
* for (... ; <+... t[idx] ...+> && idx < E ; ...)
S


Signed-off-by: Cyril Roelandt 
---
 drivers/net/wireless/mwifiex/join.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mwifiex/join.c 
b/drivers/net/wireless/mwifiex/join.c
index 893d809..f0a634d 100644
--- a/drivers/net/wireless/mwifiex/join.c
+++ b/drivers/net/wireless/mwifiex/join.c
@@ -157,8 +157,8 @@ static int mwifiex_get_common_rates(struct mwifiex_private 
*priv, u8 *rate1,
 
memset(rate1, 0, rate1_size);
 
-   for (i = 0; rate2[i] && i < rate2_size; i++) {
-   for (j = 0; tmp[j] && j < rate1_size; j++) {
+   for (i = 0; i < rate2_size && rate2[i]; i++) {
+   for (j = 0; j < rate1_size && tmp[j]; j++) {
/* Check common rate, excluding the bit for
   basic rate */
if ((rate2[i] & 0x7F) == (tmp[j] & 0x7F)) {
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mwifiex: avoid out of bounds access in mwifiex_get_common_rates.

2013-01-27 Thread Cyril Roelandt
Check that the array indexes are in-bounds before accessing the rate2 and tmp
arrays.

Found with the following semantic patch:

smpl
@@
identifier t;
identifier idx;
expression E;
statement S;
@@
* for (... ; +... t[idx] ...+  idx  E ; ...)
S
/smpl

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/net/wireless/mwifiex/join.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mwifiex/join.c 
b/drivers/net/wireless/mwifiex/join.c
index 893d809..f0a634d 100644
--- a/drivers/net/wireless/mwifiex/join.c
+++ b/drivers/net/wireless/mwifiex/join.c
@@ -157,8 +157,8 @@ static int mwifiex_get_common_rates(struct mwifiex_private 
*priv, u8 *rate1,
 
memset(rate1, 0, rate1_size);
 
-   for (i = 0; rate2[i]  i  rate2_size; i++) {
-   for (j = 0; tmp[j]  j  rate1_size; j++) {
+   for (i = 0; i  rate2_size  rate2[i]; i++) {
+   for (j = 0; j  rate1_size  tmp[j]; j++) {
/* Check common rate, excluding the bit for
   basic rate */
if ((rate2[i]  0x7F) == (tmp[j]  0x7F)) {
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/5] staging: omap-thermal: fix error check in omap_thermal_expose_sensor() and in omap_thermal_register_cpu_cooling().

2012-12-11 Thread Cyril Roelandt

The omap_bandgap_get_sensor_data() function returns ERR_PTR(), so we need to use
IS_ERR() rather than a NULL check.

Signed-off-by: Cyril Roelandt 
---
 drivers/staging/omap-thermal/omap-thermal-common.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/omap-thermal/omap-thermal-common.c 
b/drivers/staging/omap-thermal/omap-thermal-common.c
index 61f1070..79a55aa 100644
--- a/drivers/staging/omap-thermal/omap-thermal-common.c
+++ b/drivers/staging/omap-thermal/omap-thermal-common.c
@@ -260,7 +260,7 @@ int omap_thermal_expose_sensor(struct omap_bandgap *bg_ptr, 
int id,
 
data = omap_bandgap_get_sensor_data(bg_ptr, id);
 
-   if (!data)
+   if (IS_ERR(data))
data = omap_thermal_build_data(bg_ptr, id);
 
if (!data)
@@ -309,7 +309,7 @@ int omap_thermal_register_cpu_cooling(struct omap_bandgap 
*bg_ptr, int id)
struct omap_thermal_data *data;
 
data = omap_bandgap_get_sensor_data(bg_ptr, id);
-   if (!data)
+   if (IS_ERR(data))
data = omap_thermal_build_data(bg_ptr, id);
 
if (!data)
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/5] media: davinci: fix return value check in vpbe_display_reqbufs().

2012-12-11 Thread Cyril Roelandt
vb2_dma_contig_init_ctx() returns ERR_PTR and never returns NULL, so IS_ERR
should be used instead of a NULL check.

Signed-off-by: Cyril Roelandt 
---
 drivers/media/platform/davinci/vpbe_display.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/davinci/vpbe_display.c 
b/drivers/media/platform/davinci/vpbe_display.c
index 2bfde79..2db4eff 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -1393,7 +1393,7 @@ static int vpbe_display_reqbufs(struct file *file, void 
*priv,
}
/* Initialize videobuf queue as per the buffer type */
layer->alloc_ctx = vb2_dma_contig_init_ctx(vpbe_dev->pdev);
-   if (!layer->alloc_ctx) {
+   if (IS_ERR(layer->alloc_ctx)) {
v4l2_err(_dev->v4l2_dev, "Failed to get the context\n");
return -EINVAL;
}
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/5] Use IS_ERR() rather than a NULL check when necessary.

2012-12-11 Thread Cyril Roelandt
The following five patches replace NULL checks by calls to IS_ERR() when
checking the return values of functions that return ERR_PTR() on error.

Regards,
Cyril Roelandt.
---

Cyril Roelandt (5):
  staging: omap-thermal: fix error check in
omap_thermal_expose_sensor() and in
omap_thermal_register_cpu_cooling().
  media: davinci: fix return value check in vpbe_display_reqbufs().
  c2port: fix return value check in duramar2150_c2port_init().
  net: sfc: fix return value check in efx_ptp_probe_channel().
  spi: fix return value check in hspi_probe().

 drivers/media/platform/davinci/vpbe_display.c  |2 +-
 drivers/misc/c2port/c2port-duramar2150.c   |2 +-
 drivers/net/ethernet/sfc/ptp.c |2 +-
 drivers/spi/spi-sh-hspi.c  |2 +-
 drivers/staging/omap-thermal/omap-thermal-common.c |4 ++--
 5 files changed, 6 insertions(+), 6 deletions(-)

-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/5] net: sfc: fix return value check in efx_ptp_probe_channel().

2012-12-11 Thread Cyril Roelandt
The ptp_clock_register() returns ERR_PTR() and never returns NULL. Replace the
NULL check by a call to IS_ERR().

Signed-off-by: Cyril Roelandt 
---
 drivers/net/ethernet/sfc/ptp.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
index 0767043f..9bcc38c 100644
--- a/drivers/net/ethernet/sfc/ptp.c
+++ b/drivers/net/ethernet/sfc/ptp.c
@@ -930,7 +930,7 @@ static int efx_ptp_probe_channel(struct efx_channel 
*channel)
 
ptp->phc_clock = ptp_clock_register(>phc_clock_info,
>pci_dev->dev);
-   if (!ptp->phc_clock)
+   if (IS_ERR(ptp->phc_clock))
goto fail3;
 
INIT_WORK(>pps_work, efx_ptp_pps_worker);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/5] c2port: fix return value check in duramar2150_c2port_init().

2012-12-11 Thread Cyril Roelandt
The c2port_device_register() function returns ERR_PTR() and never returns NULL,
so the NULL check should be replaced by a call to IS_ERR().

Signed-off-by: Cyril Roelandt 
---
 drivers/misc/c2port/c2port-duramar2150.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/c2port/c2port-duramar2150.c 
b/drivers/misc/c2port/c2port-duramar2150.c
index 5484301..2742e60 100644
--- a/drivers/misc/c2port/c2port-duramar2150.c
+++ b/drivers/misc/c2port/c2port-duramar2150.c
@@ -129,7 +129,7 @@ static int __init duramar2150_c2port_init(void)
 
duramar2150_c2port_dev = c2port_device_register("uc",
_c2port_ops, NULL);
-   if (!duramar2150_c2port_dev) {
+   if (IS_ERR(duramar2150_c2port_dev)) {
ret = -ENODEV;
goto free_region;
}
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/5] spi: fix return value check in hspi_probe().

2012-12-11 Thread Cyril Roelandt
According to its documentation, clk_get() returns a "valid IS_ERR() condition
containing errno", so we should call IS_ERR() rather than a NULL check.

Signed-off-by: Cyril Roelandt 
---
 drivers/spi/spi-sh-hspi.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-sh-hspi.c b/drivers/spi/spi-sh-hspi.c
index 32f7b55..60cfae5 100644
--- a/drivers/spi/spi-sh-hspi.c
+++ b/drivers/spi/spi-sh-hspi.c
@@ -290,7 +290,7 @@ static int hspi_probe(struct platform_device *pdev)
}
 
clk = clk_get(NULL, "shyway_clk");
-   if (!clk) {
+   if (IS_ERR(clk)) {
dev_err(>dev, "shyway_clk is required\n");
ret = -EINVAL;
goto error0;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/5] spi: fix return value check in hspi_probe().

2012-12-11 Thread Cyril Roelandt
According to its documentation, clk_get() returns a valid IS_ERR() condition
containing errno, so we should call IS_ERR() rather than a NULL check.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/spi/spi-sh-hspi.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-sh-hspi.c b/drivers/spi/spi-sh-hspi.c
index 32f7b55..60cfae5 100644
--- a/drivers/spi/spi-sh-hspi.c
+++ b/drivers/spi/spi-sh-hspi.c
@@ -290,7 +290,7 @@ static int hspi_probe(struct platform_device *pdev)
}
 
clk = clk_get(NULL, shyway_clk);
-   if (!clk) {
+   if (IS_ERR(clk)) {
dev_err(pdev-dev, shyway_clk is required\n);
ret = -EINVAL;
goto error0;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/5] c2port: fix return value check in duramar2150_c2port_init().

2012-12-11 Thread Cyril Roelandt
The c2port_device_register() function returns ERR_PTR() and never returns NULL,
so the NULL check should be replaced by a call to IS_ERR().

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/misc/c2port/c2port-duramar2150.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/c2port/c2port-duramar2150.c 
b/drivers/misc/c2port/c2port-duramar2150.c
index 5484301..2742e60 100644
--- a/drivers/misc/c2port/c2port-duramar2150.c
+++ b/drivers/misc/c2port/c2port-duramar2150.c
@@ -129,7 +129,7 @@ static int __init duramar2150_c2port_init(void)
 
duramar2150_c2port_dev = c2port_device_register(uc,
duramar2150_c2port_ops, NULL);
-   if (!duramar2150_c2port_dev) {
+   if (IS_ERR(duramar2150_c2port_dev)) {
ret = -ENODEV;
goto free_region;
}
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/5] net: sfc: fix return value check in efx_ptp_probe_channel().

2012-12-11 Thread Cyril Roelandt
The ptp_clock_register() returns ERR_PTR() and never returns NULL. Replace the
NULL check by a call to IS_ERR().

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/net/ethernet/sfc/ptp.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
index 0767043f..9bcc38c 100644
--- a/drivers/net/ethernet/sfc/ptp.c
+++ b/drivers/net/ethernet/sfc/ptp.c
@@ -930,7 +930,7 @@ static int efx_ptp_probe_channel(struct efx_channel 
*channel)
 
ptp-phc_clock = ptp_clock_register(ptp-phc_clock_info,
efx-pci_dev-dev);
-   if (!ptp-phc_clock)
+   if (IS_ERR(ptp-phc_clock))
goto fail3;
 
INIT_WORK(ptp-pps_work, efx_ptp_pps_worker);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/5] Use IS_ERR() rather than a NULL check when necessary.

2012-12-11 Thread Cyril Roelandt
The following five patches replace NULL checks by calls to IS_ERR() when
checking the return values of functions that return ERR_PTR() on error.

Regards,
Cyril Roelandt.
---

Cyril Roelandt (5):
  staging: omap-thermal: fix error check in
omap_thermal_expose_sensor() and in
omap_thermal_register_cpu_cooling().
  media: davinci: fix return value check in vpbe_display_reqbufs().
  c2port: fix return value check in duramar2150_c2port_init().
  net: sfc: fix return value check in efx_ptp_probe_channel().
  spi: fix return value check in hspi_probe().

 drivers/media/platform/davinci/vpbe_display.c  |2 +-
 drivers/misc/c2port/c2port-duramar2150.c   |2 +-
 drivers/net/ethernet/sfc/ptp.c |2 +-
 drivers/spi/spi-sh-hspi.c  |2 +-
 drivers/staging/omap-thermal/omap-thermal-common.c |4 ++--
 5 files changed, 6 insertions(+), 6 deletions(-)

-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/5] media: davinci: fix return value check in vpbe_display_reqbufs().

2012-12-11 Thread Cyril Roelandt
vb2_dma_contig_init_ctx() returns ERR_PTR and never returns NULL, so IS_ERR
should be used instead of a NULL check.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/media/platform/davinci/vpbe_display.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/davinci/vpbe_display.c 
b/drivers/media/platform/davinci/vpbe_display.c
index 2bfde79..2db4eff 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -1393,7 +1393,7 @@ static int vpbe_display_reqbufs(struct file *file, void 
*priv,
}
/* Initialize videobuf queue as per the buffer type */
layer-alloc_ctx = vb2_dma_contig_init_ctx(vpbe_dev-pdev);
-   if (!layer-alloc_ctx) {
+   if (IS_ERR(layer-alloc_ctx)) {
v4l2_err(vpbe_dev-v4l2_dev, Failed to get the context\n);
return -EINVAL;
}
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/5] staging: omap-thermal: fix error check in omap_thermal_expose_sensor() and in omap_thermal_register_cpu_cooling().

2012-12-11 Thread Cyril Roelandt

The omap_bandgap_get_sensor_data() function returns ERR_PTR(), so we need to use
IS_ERR() rather than a NULL check.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/staging/omap-thermal/omap-thermal-common.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/omap-thermal/omap-thermal-common.c 
b/drivers/staging/omap-thermal/omap-thermal-common.c
index 61f1070..79a55aa 100644
--- a/drivers/staging/omap-thermal/omap-thermal-common.c
+++ b/drivers/staging/omap-thermal/omap-thermal-common.c
@@ -260,7 +260,7 @@ int omap_thermal_expose_sensor(struct omap_bandgap *bg_ptr, 
int id,
 
data = omap_bandgap_get_sensor_data(bg_ptr, id);
 
-   if (!data)
+   if (IS_ERR(data))
data = omap_thermal_build_data(bg_ptr, id);
 
if (!data)
@@ -309,7 +309,7 @@ int omap_thermal_register_cpu_cooling(struct omap_bandgap 
*bg_ptr, int id)
struct omap_thermal_data *data;
 
data = omap_bandgap_get_sensor_data(bg_ptr, id);
-   if (!data)
+   if (IS_ERR(data))
data = omap_thermal_build_data(bg_ptr, id);
 
if (!data)
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] media: saa7146: don't use mutex_lock_interruptible() in device_release().

2012-12-10 Thread Cyril Roelandt
Use uninterruptible mutex_lock in the release() file op to make sure all
resources are properly freed when a process is being terminated. Returning
-ERESTARTSYS has no effect for a terminating process and this may cause driver
resources not to be released.

This was found using the following semantic patch (http://coccinelle.lip6.fr/):


@r@
identifier fops;
identifier release_func;
@@
static const struct v4l2_file_operations fops = {
.release = release_func
};

@depends on r@
identifier r.release_func;
expression E;
@@
static int release_func(...)
{
...
- if (mutex_lock_interruptible(E)) return -ERESTARTSYS;
+ mutex_lock(E);
...
}


Signed-off-by: Cyril Roelandt 
---
 drivers/media/common/saa7146/saa7146_fops.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/common/saa7146/saa7146_fops.c 
b/drivers/media/common/saa7146/saa7146_fops.c
index b3890bd..0afe98d 100644
--- a/drivers/media/common/saa7146/saa7146_fops.c
+++ b/drivers/media/common/saa7146/saa7146_fops.c
@@ -265,8 +265,7 @@ static int fops_release(struct file *file)
 
DEB_EE("file:%p\n", file);
 
-   if (mutex_lock_interruptible(vdev->lock))
-   return -ERESTARTSYS;
+   mutex_lock(vdev->lock);
 
if (vdev->vfl_type == VFL_TYPE_VBI) {
if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE)
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/1] media: saa7146: don't use mutex_lock_interruptible in

2012-12-10 Thread Cyril Roelandt
This is the same kind of bug as the one fixed by
ddc43d6dc7df0849fe41b91460fa76145cf87b67 : mutex_lock() must be used in the
device_release file operation in order for all resources to be freed, since
returning -RESTARTSYS has no effect here.

I stole the commit log from Sylwester Nawrocki, who fixed a few of these issues,
since I could not formulate it better.

---

Cyril Roelandt (1):
  media: saa7146: don't use mutex_lock_interruptible() in
device_release().

 drivers/media/common/saa7146/saa7146_fops.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] staging: rtl8712: avoid a useless call to memset().

2012-12-10 Thread Cyril Roelandt
In r8711_wx_get_wap(), make sure we do not call memcpy() on a memory area that
has just been zeroed by a call to memset().

Signed-off-by: Cyril Roelandt 
---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c 
b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 3a64790..72c51b3 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1131,11 +1131,11 @@ static int r8711_wx_get_wap(struct net_device *dev,
struct ndis_wlan_bssid_ex *pcur_bss = >cur_network.network;
 
wrqu->ap_addr.sa_family = ARPHRD_ETHER;
-   memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
-   if (check_fwstate(pmlmepriv, _FW_LINKED |
-   WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) {
+   if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE |
+WIFI_AP_STATE))
memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN);
-   }
+   else
+   memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
return 0;
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] staging: rtl8712: avoid a useless call to memset().

2012-12-10 Thread Cyril Roelandt
In r8711_wx_get_wap(), make sure we do not call memcpy() on a memory area that
has just been zeroed by a call to memset().

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c 
b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 3a64790..72c51b3 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1131,11 +1131,11 @@ static int r8711_wx_get_wap(struct net_device *dev,
struct ndis_wlan_bssid_ex *pcur_bss = pmlmepriv-cur_network.network;
 
wrqu-ap_addr.sa_family = ARPHRD_ETHER;
-   memset(wrqu-ap_addr.sa_data, 0, ETH_ALEN);
-   if (check_fwstate(pmlmepriv, _FW_LINKED |
-   WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) {
+   if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE |
+WIFI_AP_STATE))
memcpy(wrqu-ap_addr.sa_data, pcur_bss-MacAddress, ETH_ALEN);
-   }
+   else
+   memset(wrqu-ap_addr.sa_data, 0, ETH_ALEN);
return 0;
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/1] media: saa7146: don't use mutex_lock_interruptible in

2012-12-10 Thread Cyril Roelandt
This is the same kind of bug as the one fixed by
ddc43d6dc7df0849fe41b91460fa76145cf87b67 : mutex_lock() must be used in the
device_release file operation in order for all resources to be freed, since
returning -RESTARTSYS has no effect here.

I stole the commit log from Sylwester Nawrocki, who fixed a few of these issues,
since I could not formulate it better.

---

Cyril Roelandt (1):
  media: saa7146: don't use mutex_lock_interruptible() in
device_release().

 drivers/media/common/saa7146/saa7146_fops.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] media: saa7146: don't use mutex_lock_interruptible() in device_release().

2012-12-10 Thread Cyril Roelandt
Use uninterruptible mutex_lock in the release() file op to make sure all
resources are properly freed when a process is being terminated. Returning
-ERESTARTSYS has no effect for a terminating process and this may cause driver
resources not to be released.

This was found using the following semantic patch (http://coccinelle.lip6.fr/):

spml
@r@
identifier fops;
identifier release_func;
@@
static const struct v4l2_file_operations fops = {
.release = release_func
};

@depends on r@
identifier r.release_func;
expression E;
@@
static int release_func(...)
{
...
- if (mutex_lock_interruptible(E)) return -ERESTARTSYS;
+ mutex_lock(E);
...
}
/spml

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/media/common/saa7146/saa7146_fops.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/common/saa7146/saa7146_fops.c 
b/drivers/media/common/saa7146/saa7146_fops.c
index b3890bd..0afe98d 100644
--- a/drivers/media/common/saa7146/saa7146_fops.c
+++ b/drivers/media/common/saa7146/saa7146_fops.c
@@ -265,8 +265,7 @@ static int fops_release(struct file *file)
 
DEB_EE(file:%p\n, file);
 
-   if (mutex_lock_interruptible(vdev-lock))
-   return -ERESTARTSYS;
+   mutex_lock(vdev-lock);
 
if (vdev-vfl_type == VFL_TYPE_VBI) {
if (dev-ext_vv_data-capabilities  V4L2_CAP_VBI_CAPTURE)
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] staging: rtl8712: avoid a useless call to memset().

2012-12-08 Thread Cyril Roelandt

On 12/05/2012 08:11 AM, Dan Carpenter wrote:

On Wed, Dec 05, 2012 at 02:22:02AM +0100, Cyril Roelandt wrote:

In r8711_wx_get_wap(), make sure we do not call memcpy() on a memory area that
has just been zeroed by a call to memset().



I look at it like the original code is fine.  Your version is also
fine but is it worth the churn?  Also the curly braces are not
needed.



Sorry about the braces.

I just thought the code would be easier to understand this way, but it's 
probably OK to leave it as it currently is too.


WBR,
Cyril Roelandt.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] staging: rtl8712: avoid a useless call to memset().

2012-12-08 Thread Cyril Roelandt

On 12/05/2012 08:11 AM, Dan Carpenter wrote:

On Wed, Dec 05, 2012 at 02:22:02AM +0100, Cyril Roelandt wrote:

In r8711_wx_get_wap(), make sure we do not call memcpy() on a memory area that
has just been zeroed by a call to memset().



I look at it like the original code is fine.  Your version is also
fine but is it worth the churn?  Also the curly braces are not
needed.



Sorry about the braces.

I just thought the code would be easier to understand this way, but it's 
probably OK to leave it as it currently is too.


WBR,
Cyril Roelandt.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: rtl8712: avoid a useless call to memset().

2012-12-04 Thread Cyril Roelandt
In r8711_wx_get_wap(), make sure we do not call memcpy() on a memory area that
has just been zeroed by a call to memset().

Signed-off-by: Cyril Roelandt 
---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c 
b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 3a64790..2c73319 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1131,10 +1131,11 @@ static int r8711_wx_get_wap(struct net_device *dev,
struct ndis_wlan_bssid_ex *pcur_bss = >cur_network.network;
 
wrqu->ap_addr.sa_family = ARPHRD_ETHER;
-   memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
if (check_fwstate(pmlmepriv, _FW_LINKED |
WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) {
memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN);
+   } else {
+   memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
}
return 0;
 }
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: csr: remove unneeded call to memset().

2012-12-04 Thread Cyril Roelandt
In uf_send_pkt_to_encrypt(), the memory area zeroed by this call to memset() is
overwritten by a call to memcpy() a few instructions later, so it is not needed.

Signed-off-by: Cyril Roelandt 
---
 drivers/staging/csr/unifi_sme.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/csr/unifi_sme.c b/drivers/staging/csr/unifi_sme.c
index 7c6c413..7669037 100644
--- a/drivers/staging/csr/unifi_sme.c
+++ b/drivers/staging/csr/unifi_sme.c
@@ -1196,7 +1196,6 @@ void uf_send_pkt_to_encrypt(struct work_struct *work)
 
 if (pktBulkDataLength > 0) {
pktBulkData = kmalloc(pktBulkDataLength, GFP_KERNEL);
-   memset(pktBulkData, 0, pktBulkDataLength);
} else {
unifi_error(priv, "uf_send_pkt_to_encrypt() : invalid 
buffer\n");
return;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: wlags49_h2: remove unneeded memset() in wireless_get_bssid()

2012-12-04 Thread Cyril Roelandt
A few lines after this call, we memcpy over the same memory area, so the call to
memset is not necessary.

Signed-off-by: Cyril Roelandt 
---
 drivers/staging/wlags49_h2/wl_wext.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/wlags49_h2/wl_wext.c 
b/drivers/staging/wlags49_h2/wl_wext.c
index f553366..c731ff2 100644
--- a/drivers/staging/wlags49_h2/wl_wext.c
+++ b/drivers/staging/wlags49_h2/wl_wext.c
@@ -796,8 +796,6 @@ static int wireless_get_bssid(struct net_device *dev, 
struct iw_request_info *in
 
wl_act_int_off( lp );
 
-   memset( _addr->sa_data, 0, ETH_ALEN );
-
ap_addr->sa_family = ARPHRD_ETHER;
 
/* Assume AP mode here, which means the BSSID is our own MAC address. In
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: wlags49_h2: remove unneeded memset() in wireless_get_bssid()

2012-12-04 Thread Cyril Roelandt
A few lines after this call, we memcpy over the same memory area, so the call to
memset is not necessary.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/staging/wlags49_h2/wl_wext.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/wlags49_h2/wl_wext.c 
b/drivers/staging/wlags49_h2/wl_wext.c
index f553366..c731ff2 100644
--- a/drivers/staging/wlags49_h2/wl_wext.c
+++ b/drivers/staging/wlags49_h2/wl_wext.c
@@ -796,8 +796,6 @@ static int wireless_get_bssid(struct net_device *dev, 
struct iw_request_info *in
 
wl_act_int_off( lp );
 
-   memset( ap_addr-sa_data, 0, ETH_ALEN );
-
ap_addr-sa_family = ARPHRD_ETHER;
 
/* Assume AP mode here, which means the BSSID is our own MAC address. In
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: csr: remove unneeded call to memset().

2012-12-04 Thread Cyril Roelandt
In uf_send_pkt_to_encrypt(), the memory area zeroed by this call to memset() is
overwritten by a call to memcpy() a few instructions later, so it is not needed.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/staging/csr/unifi_sme.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/csr/unifi_sme.c b/drivers/staging/csr/unifi_sme.c
index 7c6c413..7669037 100644
--- a/drivers/staging/csr/unifi_sme.c
+++ b/drivers/staging/csr/unifi_sme.c
@@ -1196,7 +1196,6 @@ void uf_send_pkt_to_encrypt(struct work_struct *work)
 
 if (pktBulkDataLength  0) {
pktBulkData = kmalloc(pktBulkDataLength, GFP_KERNEL);
-   memset(pktBulkData, 0, pktBulkDataLength);
} else {
unifi_error(priv, uf_send_pkt_to_encrypt() : invalid 
buffer\n);
return;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: rtl8712: avoid a useless call to memset().

2012-12-04 Thread Cyril Roelandt
In r8711_wx_get_wap(), make sure we do not call memcpy() on a memory area that
has just been zeroed by a call to memset().

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c 
b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 3a64790..2c73319 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1131,10 +1131,11 @@ static int r8711_wx_get_wap(struct net_device *dev,
struct ndis_wlan_bssid_ex *pcur_bss = pmlmepriv-cur_network.network;
 
wrqu-ap_addr.sa_family = ARPHRD_ETHER;
-   memset(wrqu-ap_addr.sa_data, 0, ETH_ALEN);
if (check_fwstate(pmlmepriv, _FW_LINKED |
WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) {
memcpy(wrqu-ap_addr.sa_data, pcur_bss-MacAddress, ETH_ALEN);
+   } else {
+   memset(wrqu-ap_addr.sa_data, 0, ETH_ALEN);
}
return 0;
 }
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/6] scsi: megaraid: remove a useless call to memset().

2012-12-01 Thread Cyril Roelandt
This call is followed by a call to memcpy() on the same memory area, so it can
be safely removed.

Signed-off-by: Cyril Roelandt 
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 74030af..71cc3eb 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -1028,8 +1028,6 @@ map_cmd_status(struct megasas_cmd_fusion *cmd, u8 status, 
u8 ext_status)
 
cmd->scmd->result = (DID_OK << 16) | ext_status;
if (ext_status == SAM_STAT_CHECK_CONDITION) {
-   memset(cmd->scmd->sense_buffer, 0,
-  SCSI_SENSE_BUFFERSIZE);
memcpy(cmd->scmd->sense_buffer, cmd->sense,
   SCSI_SENSE_BUFFERSIZE);
cmd->scmd->result |= DRIVER_SENSE << 24;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] scsi: bnx2fc: remove useless calls to memset().

2012-12-01 Thread Cyril Roelandt
These calls are followed by calls to memcpy() on the same memory area, so they
can be safely removed.

Signed-off-by: Cyril Roelandt 
---
 drivers/scsi/bnx2fc/bnx2fc_hwi.c |4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
index ef60afa..9be42b8 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
@@ -759,8 +759,6 @@ static void bnx2fc_process_unsol_compl(struct bnx2fc_rport 
*tgt, u16 wqe)
case FCOE_ERROR_CODE_DATA_SOFN_SEQ_ACTIVE_RESET:
BNX2FC_TGT_DBG(tgt, "REC TOV popped for xid - 0x%x\n",
   xid);
-   memset(_req->err_entry, 0,
-  sizeof(struct fcoe_err_report_entry));
memcpy(_req->err_entry, err_entry,
   sizeof(struct fcoe_err_report_entry));
if (!test_bit(BNX2FC_FLAG_SRR_SENT,
@@ -847,8 +845,6 @@ ret_err_rqe:
goto ret_warn_rqe;
}
 
-   memset(_req->err_entry, 0,
-  sizeof(struct fcoe_err_report_entry));
memcpy(_req->err_entry, err_entry,
   sizeof(struct fcoe_err_report_entry));
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] vt6656: remove a useless call to memset().

2012-12-01 Thread Cyril Roelandt
This call is followed by a call to memcpy() on the same memory area, so it can
be safely removed.

Signed-off-by: Cyril Roelandt 
---
 drivers/staging/vt6656/bssdb.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c
index 6a13941..f9098b8 100644
--- a/drivers/staging/vt6656/bssdb.c
+++ b/drivers/staging/vt6656/bssdb.c
@@ -240,7 +240,6 @@ pDevice->bSameBSSMaxNum = jj;
 pSelect->bSelected = TRUE;
 if (pDevice->bRoaming == FALSE)  {
//   Einsn Add @20070907
-   memset(pbyDesireSSID, 0, WLAN_IEHDR_LEN + 
WLAN_SSID_MAXLEN + 1);
memcpy(pbyDesireSSID,pCurrBSS->abySSID,WLAN_IEHDR_LEN + 
WLAN_SSID_MAXLEN + 1) ;
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] rtl8712: remove useless calls to memset().

2012-12-01 Thread Cyril Roelandt
These calls are followed by calls to memcpy() on the same memory area, so they
can be safely removed.

Signed-off-by: Cyril Roelandt 
---
 drivers/staging/rtl8712/mlme_linux.c|2 --
 drivers/staging/rtl8712/rtl871x_cmd.c   |1 -
 drivers/staging/rtl8712/rtl871x_ioctl_set.c |2 --
 drivers/staging/rtl8712/rtl871x_mlme.c  |5 -
 4 files changed, 10 deletions(-)

diff --git a/drivers/staging/rtl8712/mlme_linux.c 
b/drivers/staging/rtl8712/mlme_linux.c
index 7279854..f569a70 100644
--- a/drivers/staging/rtl8712/mlme_linux.c
+++ b/drivers/staging/rtl8712/mlme_linux.c
@@ -106,8 +106,6 @@ void r8712_os_indicate_disconnect(struct _adapter *adapter)
 * disconnect with AP for 60 seconds.
 */
 
-   memset([0], 0x00, sizeof(
-   struct RT_PMKID_LIST) * NUM_PMKID_CACHE);
memcpy([0], >securitypriv.
PMKIDList[0], sizeof(struct RT_PMKID_LIST) *
NUM_PMKID_CACHE);
diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c 
b/drivers/staging/rtl8712/rtl871x_cmd.c
index 31f31dbf..f16307f 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.c
+++ b/drivers/staging/rtl8712/rtl871x_cmd.c
@@ -525,7 +525,6 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct 
wlan_network *pnetwork)
kfree(pcmd);
return _FAIL;
}
-   memset(psecnetwork, 0, t_len);
memcpy(psecnetwork, >network, t_len);
auth = >authenticator_ie[0];
psecuritypriv->authenticator_ie[0] = (unsigned char)
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c 
b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
index d3ab24e..53a7c8c 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
@@ -97,8 +97,6 @@ static u8 do_join(struct _adapter *padapter)
pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
pibss = padapter->registrypriv.dev_network.
MacAddress;
-   memset(_network->Ssid, 0,
-   sizeof(struct ndis_802_11_ssid));
memcpy(_network->Ssid,
>assoc_ssid,
sizeof(struct ndis_802_11_ssid));
diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c 
b/drivers/staging/rtl8712/rtl871x_mlme.c
index c51ad9e..e52f04d 100644
--- a/drivers/staging/rtl8712/rtl871x_mlme.c
+++ b/drivers/staging/rtl8712/rtl871x_mlme.c
@@ -604,9 +604,6 @@ void r8712_surveydone_event_callback(struct _adapter 
*adapter, u8 *pbuf)
 adapter->registrypriv.
dev_network.MacAddress;
pmlmepriv->fw_state ^= _FW_UNDER_SURVEY;
-   memset(_network->Ssid, 0,
-   sizeof(struct
-  ndis_802_11_ssid));
memcpy(_network->Ssid,
>assoc_ssid,
sizeof(struct
@@ -1006,8 +1003,6 @@ void r8712_stadel_event_callback(struct _adapter 
*adapter, u8 *pbuf)
memcpy(pdev_network, _network->network,
r8712_get_ndis_wlan_bssid_ex_sz(_network->
network));
-   memset(_network->Ssid, 0,
-   sizeof(struct ndis_802_11_ssid));
memcpy(_network->Ssid,
>assoc_ssid,
sizeof(struct ndis_802_11_ssid));
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6] bna: remove useless calls to memset().

2012-12-01 Thread Cyril Roelandt
These calls are followed by calls to memcpy() on the same memory area, so they
can safely be removed.

Signed-off-by: Cyril Roelandt 
---
 drivers/net/ethernet/brocade/bna/bfa_ioc.c |4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.c 
b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
index 959c58e..3227fdd 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_ioc.c
+++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
@@ -2273,7 +2273,6 @@ bfa_ioc_get_type(struct bfa_ioc *ioc)
 static void
 bfa_ioc_get_adapter_serial_num(struct bfa_ioc *ioc, char *serial_num)
 {
-   memset(serial_num, 0, BFA_ADAPTER_SERIAL_NUM_LEN);
memcpy(serial_num,
(void *)ioc->attr->brcd_serialnum,
BFA_ADAPTER_SERIAL_NUM_LEN);
@@ -2282,7 +2281,6 @@ bfa_ioc_get_adapter_serial_num(struct bfa_ioc *ioc, char 
*serial_num)
 static void
 bfa_ioc_get_adapter_fw_ver(struct bfa_ioc *ioc, char *fw_ver)
 {
-   memset(fw_ver, 0, BFA_VERSION_LEN);
memcpy(fw_ver, ioc->attr->fw_version, BFA_VERSION_LEN);
 }
 
@@ -2304,7 +2302,6 @@ bfa_ioc_get_pci_chip_rev(struct bfa_ioc *ioc, char 
*chip_rev)
 static void
 bfa_ioc_get_adapter_optrom_ver(struct bfa_ioc *ioc, char *optrom_ver)
 {
-   memset(optrom_ver, 0, BFA_VERSION_LEN);
memcpy(optrom_ver, ioc->attr->optrom_version,
  BFA_VERSION_LEN);
 }
@@ -2312,7 +2309,6 @@ bfa_ioc_get_adapter_optrom_ver(struct bfa_ioc *ioc, char 
*optrom_ver)
 static void
 bfa_ioc_get_adapter_manufacturer(struct bfa_ioc *ioc, char *manufacturer)
 {
-   memset(manufacturer, 0, BFA_ADAPTER_MFG_NAME_LEN);
memcpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN);
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] scsi: bfa: remove useless calls to memset().

2012-12-01 Thread Cyril Roelandt
These calls are followed by calls to memcpy() on the same memory area, so they
can safely be removed.

Signed-off-by: Cyril Roelandt 
---
 drivers/scsi/bfa/bfa_ioc.c  |1 -
 drivers/scsi/bfa/bfad_bsg.c |1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
index 0116c10..dd2a2ef 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -2517,7 +2517,6 @@ bfa_ioc_get_type(struct bfa_ioc_s *ioc)
 void
 bfa_ioc_get_adapter_serial_num(struct bfa_ioc_s *ioc, char *serial_num)
 {
-   memset((void *)serial_num, 0, BFA_ADAPTER_SERIAL_NUM_LEN);
memcpy((void *)serial_num,
(void *)ioc->attr->brcd_serialnum,
BFA_ADAPTER_SERIAL_NUM_LEN);
diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c
index 555e7db..9527fdb 100644
--- a/drivers/scsi/bfa/bfad_bsg.c
+++ b/drivers/scsi/bfa/bfad_bsg.c
@@ -3197,7 +3197,6 @@ bfad_fcxp_map_sg(struct bfad_s *bfad, void *payload_kbuf,
goto out_free_mem;
 
/* copy the linear bsg buffer to buf_info */
-   memset(buf_info->virt, 0, buf_info->size);
memcpy(buf_info->virt, payload_kbuf, buf_info->size);
 
/*
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/6] Remove useless calls to memset().

2012-12-01 Thread Cyril Roelandt
The following six patches remove useless calls to memset(). They have been found
with this Coccinelle script:


@@
expression E;
expression S;
@@
-memset(E, 0, S);
 memcpy(E, ..., S);


They have only been tested by compilation.

WBR,
Cyril Roelandt.


Cyril Roelandt (6):
  bna: remove useless calls to memset().
  scsi: bfa: remove useless calls to memset().
  scsi: bnx2fc: remove useless calls to memset().
  scsi: megaraid: remove a useless call to memset().
  rtl8712: remove useless calls to memset().
  vt6656: remove a useless call to memset().

 drivers/net/ethernet/brocade/bna/bfa_ioc.c  |4 
 drivers/scsi/bfa/bfa_ioc.c  |1 -
 drivers/scsi/bfa/bfad_bsg.c |1 -
 drivers/scsi/bnx2fc/bnx2fc_hwi.c|4 
 drivers/scsi/megaraid/megaraid_sas_fusion.c |2 --
 drivers/staging/rtl8712/mlme_linux.c|2 --
 drivers/staging/rtl8712/rtl871x_cmd.c   |1 -
 drivers/staging/rtl8712/rtl871x_ioctl_set.c |2 --
 drivers/staging/rtl8712/rtl871x_mlme.c  |5 -
 drivers/staging/vt6656/bssdb.c  |1 -
 10 files changed, 23 deletions(-)

-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/6] Remove useless calls to memset().

2012-12-01 Thread Cyril Roelandt
The following six patches remove useless calls to memset(). They have been found
with this Coccinelle script:

spml
@@
expression E;
expression S;
@@
-memset(E, 0, S);
 memcpy(E, ..., S);
/spml

They have only been tested by compilation.

WBR,
Cyril Roelandt.


Cyril Roelandt (6):
  bna: remove useless calls to memset().
  scsi: bfa: remove useless calls to memset().
  scsi: bnx2fc: remove useless calls to memset().
  scsi: megaraid: remove a useless call to memset().
  rtl8712: remove useless calls to memset().
  vt6656: remove a useless call to memset().

 drivers/net/ethernet/brocade/bna/bfa_ioc.c  |4 
 drivers/scsi/bfa/bfa_ioc.c  |1 -
 drivers/scsi/bfa/bfad_bsg.c |1 -
 drivers/scsi/bnx2fc/bnx2fc_hwi.c|4 
 drivers/scsi/megaraid/megaraid_sas_fusion.c |2 --
 drivers/staging/rtl8712/mlme_linux.c|2 --
 drivers/staging/rtl8712/rtl871x_cmd.c   |1 -
 drivers/staging/rtl8712/rtl871x_ioctl_set.c |2 --
 drivers/staging/rtl8712/rtl871x_mlme.c  |5 -
 drivers/staging/vt6656/bssdb.c  |1 -
 10 files changed, 23 deletions(-)

-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] scsi: bfa: remove useless calls to memset().

2012-12-01 Thread Cyril Roelandt
These calls are followed by calls to memcpy() on the same memory area, so they
can safely be removed.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/scsi/bfa/bfa_ioc.c  |1 -
 drivers/scsi/bfa/bfad_bsg.c |1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
index 0116c10..dd2a2ef 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -2517,7 +2517,6 @@ bfa_ioc_get_type(struct bfa_ioc_s *ioc)
 void
 bfa_ioc_get_adapter_serial_num(struct bfa_ioc_s *ioc, char *serial_num)
 {
-   memset((void *)serial_num, 0, BFA_ADAPTER_SERIAL_NUM_LEN);
memcpy((void *)serial_num,
(void *)ioc-attr-brcd_serialnum,
BFA_ADAPTER_SERIAL_NUM_LEN);
diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c
index 555e7db..9527fdb 100644
--- a/drivers/scsi/bfa/bfad_bsg.c
+++ b/drivers/scsi/bfa/bfad_bsg.c
@@ -3197,7 +3197,6 @@ bfad_fcxp_map_sg(struct bfad_s *bfad, void *payload_kbuf,
goto out_free_mem;
 
/* copy the linear bsg buffer to buf_info */
-   memset(buf_info-virt, 0, buf_info-size);
memcpy(buf_info-virt, payload_kbuf, buf_info-size);
 
/*
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6] bna: remove useless calls to memset().

2012-12-01 Thread Cyril Roelandt
These calls are followed by calls to memcpy() on the same memory area, so they
can safely be removed.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/net/ethernet/brocade/bna/bfa_ioc.c |4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.c 
b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
index 959c58e..3227fdd 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_ioc.c
+++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.c
@@ -2273,7 +2273,6 @@ bfa_ioc_get_type(struct bfa_ioc *ioc)
 static void
 bfa_ioc_get_adapter_serial_num(struct bfa_ioc *ioc, char *serial_num)
 {
-   memset(serial_num, 0, BFA_ADAPTER_SERIAL_NUM_LEN);
memcpy(serial_num,
(void *)ioc-attr-brcd_serialnum,
BFA_ADAPTER_SERIAL_NUM_LEN);
@@ -2282,7 +2281,6 @@ bfa_ioc_get_adapter_serial_num(struct bfa_ioc *ioc, char 
*serial_num)
 static void
 bfa_ioc_get_adapter_fw_ver(struct bfa_ioc *ioc, char *fw_ver)
 {
-   memset(fw_ver, 0, BFA_VERSION_LEN);
memcpy(fw_ver, ioc-attr-fw_version, BFA_VERSION_LEN);
 }
 
@@ -2304,7 +2302,6 @@ bfa_ioc_get_pci_chip_rev(struct bfa_ioc *ioc, char 
*chip_rev)
 static void
 bfa_ioc_get_adapter_optrom_ver(struct bfa_ioc *ioc, char *optrom_ver)
 {
-   memset(optrom_ver, 0, BFA_VERSION_LEN);
memcpy(optrom_ver, ioc-attr-optrom_version,
  BFA_VERSION_LEN);
 }
@@ -2312,7 +2309,6 @@ bfa_ioc_get_adapter_optrom_ver(struct bfa_ioc *ioc, char 
*optrom_ver)
 static void
 bfa_ioc_get_adapter_manufacturer(struct bfa_ioc *ioc, char *manufacturer)
 {
-   memset(manufacturer, 0, BFA_ADAPTER_MFG_NAME_LEN);
memcpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN);
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] rtl8712: remove useless calls to memset().

2012-12-01 Thread Cyril Roelandt
These calls are followed by calls to memcpy() on the same memory area, so they
can be safely removed.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/staging/rtl8712/mlme_linux.c|2 --
 drivers/staging/rtl8712/rtl871x_cmd.c   |1 -
 drivers/staging/rtl8712/rtl871x_ioctl_set.c |2 --
 drivers/staging/rtl8712/rtl871x_mlme.c  |5 -
 4 files changed, 10 deletions(-)

diff --git a/drivers/staging/rtl8712/mlme_linux.c 
b/drivers/staging/rtl8712/mlme_linux.c
index 7279854..f569a70 100644
--- a/drivers/staging/rtl8712/mlme_linux.c
+++ b/drivers/staging/rtl8712/mlme_linux.c
@@ -106,8 +106,6 @@ void r8712_os_indicate_disconnect(struct _adapter *adapter)
 * disconnect with AP for 60 seconds.
 */
 
-   memset(backupPMKIDList[0], 0x00, sizeof(
-   struct RT_PMKID_LIST) * NUM_PMKID_CACHE);
memcpy(backupPMKIDList[0], adapter-securitypriv.
PMKIDList[0], sizeof(struct RT_PMKID_LIST) *
NUM_PMKID_CACHE);
diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c 
b/drivers/staging/rtl8712/rtl871x_cmd.c
index 31f31dbf..f16307f 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.c
+++ b/drivers/staging/rtl8712/rtl871x_cmd.c
@@ -525,7 +525,6 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct 
wlan_network *pnetwork)
kfree(pcmd);
return _FAIL;
}
-   memset(psecnetwork, 0, t_len);
memcpy(psecnetwork, pnetwork-network, t_len);
auth = psecuritypriv-authenticator_ie[0];
psecuritypriv-authenticator_ie[0] = (unsigned char)
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c 
b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
index d3ab24e..53a7c8c 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
@@ -97,8 +97,6 @@ static u8 do_join(struct _adapter *padapter)
pmlmepriv-fw_state = WIFI_ADHOC_MASTER_STATE;
pibss = padapter-registrypriv.dev_network.
MacAddress;
-   memset(pdev_network-Ssid, 0,
-   sizeof(struct ndis_802_11_ssid));
memcpy(pdev_network-Ssid,
pmlmepriv-assoc_ssid,
sizeof(struct ndis_802_11_ssid));
diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c 
b/drivers/staging/rtl8712/rtl871x_mlme.c
index c51ad9e..e52f04d 100644
--- a/drivers/staging/rtl8712/rtl871x_mlme.c
+++ b/drivers/staging/rtl8712/rtl871x_mlme.c
@@ -604,9 +604,6 @@ void r8712_surveydone_event_callback(struct _adapter 
*adapter, u8 *pbuf)
 adapter-registrypriv.
dev_network.MacAddress;
pmlmepriv-fw_state ^= _FW_UNDER_SURVEY;
-   memset(pdev_network-Ssid, 0,
-   sizeof(struct
-  ndis_802_11_ssid));
memcpy(pdev_network-Ssid,
pmlmepriv-assoc_ssid,
sizeof(struct
@@ -1006,8 +1003,6 @@ void r8712_stadel_event_callback(struct _adapter 
*adapter, u8 *pbuf)
memcpy(pdev_network, tgt_network-network,
r8712_get_ndis_wlan_bssid_ex_sz(tgt_network-
network));
-   memset(pdev_network-Ssid, 0,
-   sizeof(struct ndis_802_11_ssid));
memcpy(pdev_network-Ssid,
pmlmepriv-assoc_ssid,
sizeof(struct ndis_802_11_ssid));
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] vt6656: remove a useless call to memset().

2012-12-01 Thread Cyril Roelandt
This call is followed by a call to memcpy() on the same memory area, so it can
be safely removed.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/staging/vt6656/bssdb.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c
index 6a13941..f9098b8 100644
--- a/drivers/staging/vt6656/bssdb.c
+++ b/drivers/staging/vt6656/bssdb.c
@@ -240,7 +240,6 @@ pDevice-bSameBSSMaxNum = jj;
 pSelect-bSelected = TRUE;
 if (pDevice-bRoaming == FALSE)  {
//   Einsn Add @20070907
-   memset(pbyDesireSSID, 0, WLAN_IEHDR_LEN + 
WLAN_SSID_MAXLEN + 1);
memcpy(pbyDesireSSID,pCurrBSS-abySSID,WLAN_IEHDR_LEN + 
WLAN_SSID_MAXLEN + 1) ;
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] scsi: bnx2fc: remove useless calls to memset().

2012-12-01 Thread Cyril Roelandt
These calls are followed by calls to memcpy() on the same memory area, so they
can be safely removed.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/scsi/bnx2fc/bnx2fc_hwi.c |4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
index ef60afa..9be42b8 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
@@ -759,8 +759,6 @@ static void bnx2fc_process_unsol_compl(struct bnx2fc_rport 
*tgt, u16 wqe)
case FCOE_ERROR_CODE_DATA_SOFN_SEQ_ACTIVE_RESET:
BNX2FC_TGT_DBG(tgt, REC TOV popped for xid - 0x%x\n,
   xid);
-   memset(io_req-err_entry, 0,
-  sizeof(struct fcoe_err_report_entry));
memcpy(io_req-err_entry, err_entry,
   sizeof(struct fcoe_err_report_entry));
if (!test_bit(BNX2FC_FLAG_SRR_SENT,
@@ -847,8 +845,6 @@ ret_err_rqe:
goto ret_warn_rqe;
}
 
-   memset(io_req-err_entry, 0,
-  sizeof(struct fcoe_err_report_entry));
memcpy(io_req-err_entry, err_entry,
   sizeof(struct fcoe_err_report_entry));
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/6] scsi: megaraid: remove a useless call to memset().

2012-12-01 Thread Cyril Roelandt
This call is followed by a call to memcpy() on the same memory area, so it can
be safely removed.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 74030af..71cc3eb 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -1028,8 +1028,6 @@ map_cmd_status(struct megasas_cmd_fusion *cmd, u8 status, 
u8 ext_status)
 
cmd-scmd-result = (DID_OK  16) | ext_status;
if (ext_status == SAM_STAT_CHECK_CONDITION) {
-   memset(cmd-scmd-sense_buffer, 0,
-  SCSI_SENSE_BUFFERSIZE);
memcpy(cmd-scmd-sense_buffer, cmd-sense,
   SCSI_SENSE_BUFFERSIZE);
cmd-scmd-result |= DRIVER_SENSE  24;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] UVC: use GFP_ATOMIC under spin lock.

2012-11-24 Thread Cyril Roelandt
Found using the following semantic patch:

@@
@@
spin_lock_irqsave(...);
... when != spin_unlock_irqrestore(...);
* GFP_KERNEL


Signed-off-by: Cyril Roelandt 
---
 drivers/usb/gadget/uvc_video.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/uvc_video.c b/drivers/usb/gadget/uvc_video.c
index b0e53a8..cd067a6 100644
--- a/drivers/usb/gadget/uvc_video.c
+++ b/drivers/usb/gadget/uvc_video.c
@@ -309,7 +309,8 @@ uvc_video_pump(struct uvc_video *video)
video->encode(req, video, buf);
 
/* Queue the USB request */
-   if ((ret = usb_ep_queue(video->ep, req, GFP_KERNEL)) < 0) {
+   ret = usb_ep_queue(video->ep, req, GFP_ATOMIC);
+   if (ret < 0) {
printk(KERN_INFO "Failed to queue request (%d)\n", ret);
usb_ep_set_halt(video->ep);
spin_unlock_irqrestore(>queue.irqlock, flags);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] UVC: use GFP_ATOMIC under spin lock.

2012-11-24 Thread Cyril Roelandt
Found using the following semantic patch:
spml
@@
@@
spin_lock_irqsave(...);
... when != spin_unlock_irqrestore(...);
* GFP_KERNEL
/spml

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/usb/gadget/uvc_video.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/uvc_video.c b/drivers/usb/gadget/uvc_video.c
index b0e53a8..cd067a6 100644
--- a/drivers/usb/gadget/uvc_video.c
+++ b/drivers/usb/gadget/uvc_video.c
@@ -309,7 +309,8 @@ uvc_video_pump(struct uvc_video *video)
video-encode(req, video, buf);
 
/* Queue the USB request */
-   if ((ret = usb_ep_queue(video-ep, req, GFP_KERNEL))  0) {
+   ret = usb_ep_queue(video-ep, req, GFP_ATOMIC);
+   if (ret  0) {
printk(KERN_INFO Failed to queue request (%d)\n, ret);
usb_ep_set_halt(video-ep);
spin_unlock_irqrestore(video-queue.irqlock, flags);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] acpi_system_write_wakeup_device(): fix error check for unsigned variable.

2012-11-22 Thread Cyril Roelandt

On 11/21/2012 01:44 AM, Rafael J. Wysocki wrote:

On Saturday, November 17, 2012 02:54:23 AM Cyril Roelandt wrote:

The LEN variable is unsigned, therefore checking whether it is less than 0 is
useless.

Signed-off-by: Cyril Roelandt
---
  drivers/acpi/proc.c |2 --
  1 file changed, 2 deletions(-)

diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index 27adb09..37871a7 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -366,8 +366,6 @@ acpi_system_write_wakeup_device(struct file *file,

if (len>  4)
len = 4;
-   if (len<  0)
-   return -EFAULT;


I would prefer to check if count<  0 instead.




count has type size_t, so it is also an unsigned variable. I think that 
acpi_system_write_wakeup_device really cannot be called with a "count" 
parameter that is less than 0.


WBR,
Cyril Roelandt.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] acpi_system_write_wakeup_device(): fix error check for unsigned variable.

2012-11-22 Thread Cyril Roelandt

On 11/22/2012 01:23 AM, Rafael J. Wysocki wrote:

On Thursday, November 22, 2012 01:05:30 AM Cyril Roelandt wrote:

On 11/21/2012 01:44 AM, Rafael J. Wysocki wrote:

On Saturday, November 17, 2012 02:54:23 AM Cyril Roelandt wrote:

The LEN variable is unsigned, therefore checking whether it is less than 0 is
useless.

Signed-off-by: Cyril Roelandt
---
   drivers/acpi/proc.c |2 --
   1 file changed, 2 deletions(-)

diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index 27adb09..37871a7 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -366,8 +366,6 @@ acpi_system_write_wakeup_device(struct file *file,

if (len>   4)
len = 4;
-   if (len<   0)
-   return -EFAULT;


I would prefer to check if count<   0 instead.




count has type size_t, so it is also an unsigned variable. I think that
acpi_system_write_wakeup_device really cannot be called with a "count"
parameter that is less than 0.


OK

So I suppose we can just drop len entirely and replace it with count, right?
[And drop the<  0 check too.]



Indeed, I'll resend.

Cyril Roelandt.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] acpi_system_write_wakeup_device(): fix error check for unsigned variable.

2012-11-22 Thread Cyril Roelandt
The LEN variable is unsigned, therefore checking whether it is less than 0 is
useless. Also drop the LEN variable, since the COUNT parameter can be used
instead.

Signed-off-by: Cyril Roelandt 
---
 drivers/acpi/proc.c |   11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index 27adb09..ef98796 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -362,16 +362,13 @@ acpi_system_write_wakeup_device(struct file *file,
struct list_head *node, *next;
char strbuf[5];
char str[5] = "";
-   unsigned int len = count;
 
-   if (len > 4)
-   len = 4;
-   if (len < 0)
-   return -EFAULT;
+   if (count > 4)
+   count = 4;
 
-   if (copy_from_user(strbuf, buffer, len))
+   if (copy_from_user(strbuf, buffer, count))
return -EFAULT;
-   strbuf[len] = '\0';
+   strbuf[count] = '\0';
sscanf(strbuf, "%s", str);
 
mutex_lock(_device_lock);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] acpi_system_write_wakeup_device(): fix error check for unsigned variable.

2012-11-22 Thread Cyril Roelandt
The LEN variable is unsigned, therefore checking whether it is less than 0 is
useless. Also drop the LEN variable, since the COUNT parameter can be used
instead.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/acpi/proc.c |   11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index 27adb09..ef98796 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -362,16 +362,13 @@ acpi_system_write_wakeup_device(struct file *file,
struct list_head *node, *next;
char strbuf[5];
char str[5] = ;
-   unsigned int len = count;
 
-   if (len  4)
-   len = 4;
-   if (len  0)
-   return -EFAULT;
+   if (count  4)
+   count = 4;
 
-   if (copy_from_user(strbuf, buffer, len))
+   if (copy_from_user(strbuf, buffer, count))
return -EFAULT;
-   strbuf[len] = '\0';
+   strbuf[count] = '\0';
sscanf(strbuf, %s, str);
 
mutex_lock(acpi_device_lock);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] acpi_system_write_wakeup_device(): fix error check for unsigned variable.

2012-11-22 Thread Cyril Roelandt

On 11/22/2012 01:23 AM, Rafael J. Wysocki wrote:

On Thursday, November 22, 2012 01:05:30 AM Cyril Roelandt wrote:

On 11/21/2012 01:44 AM, Rafael J. Wysocki wrote:

On Saturday, November 17, 2012 02:54:23 AM Cyril Roelandt wrote:

The LEN variable is unsigned, therefore checking whether it is less than 0 is
useless.

Signed-off-by: Cyril Roelandttipec...@gmail.com
---
   drivers/acpi/proc.c |2 --
   1 file changed, 2 deletions(-)

diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index 27adb09..37871a7 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -366,8 +366,6 @@ acpi_system_write_wakeup_device(struct file *file,

if (len   4)
len = 4;
-   if (len   0)
-   return -EFAULT;


I would prefer to check if count   0 instead.




count has type size_t, so it is also an unsigned variable. I think that
acpi_system_write_wakeup_device really cannot be called with a count
parameter that is less than 0.


OK

So I suppose we can just drop len entirely and replace it with count, right?
[And drop the  0 check too.]



Indeed, I'll resend.

Cyril Roelandt.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] acpi_system_write_wakeup_device(): fix error check for unsigned variable.

2012-11-22 Thread Cyril Roelandt

On 11/21/2012 01:44 AM, Rafael J. Wysocki wrote:

On Saturday, November 17, 2012 02:54:23 AM Cyril Roelandt wrote:

The LEN variable is unsigned, therefore checking whether it is less than 0 is
useless.

Signed-off-by: Cyril Roelandttipec...@gmail.com
---
  drivers/acpi/proc.c |2 --
  1 file changed, 2 deletions(-)

diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index 27adb09..37871a7 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -366,8 +366,6 @@ acpi_system_write_wakeup_device(struct file *file,

if (len  4)
len = 4;
-   if (len  0)
-   return -EFAULT;


I would prefer to check if count  0 instead.




count has type size_t, so it is also an unsigned variable. I think that 
acpi_system_write_wakeup_device really cannot be called with a count 
parameter that is less than 0.


WBR,
Cyril Roelandt.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mx2_camera: use GFP_ATOMIC under spin lock.

2012-11-19 Thread Cyril Roelandt
Found using the following semantic patch:


@@
@@
spin_lock_irqsave(...);
... when != spin_unlock_irqrestore(...);
* GFP_KERNEL


Signed-off-by: Cyril Roelandt 
---
 drivers/media/platform/soc_camera/mx2_camera.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/mx2_camera.c 
b/drivers/media/platform/soc_camera/mx2_camera.c
index e575ae8..516b3a3 100644
--- a/drivers/media/platform/soc_camera/mx2_camera.c
+++ b/drivers/media/platform/soc_camera/mx2_camera.c
@@ -909,7 +909,7 @@ static int mx2_start_streaming(struct vb2_queue *q, 
unsigned int count)
pcdev->discard_size = icd->user_height * bytesperline;
pcdev->discard_buffer = dma_alloc_coherent(ici->v4l2_dev.dev,
pcdev->discard_size, >discard_buffer_dma,
-   GFP_KERNEL);
+   GFP_ATOMIC);
if (!pcdev->discard_buffer)
return -ENOMEM;
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] UVC: use GFP_ATOMIC under spin lock.

2012-11-19 Thread Cyril Roelandt
Found using the following semantic patch:

@@
@@
spin_lock_irqsave(...);
... when != spin_unlock_irqrestore(...);
* GFP_KERNEL


Signed-off-by: Cyril Roelandt 
---
 drivers/usb/gadget/uvc_video.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/uvc_video.c b/drivers/usb/gadget/uvc_video.c
index b0e53a8..79b4132 100644
--- a/drivers/usb/gadget/uvc_video.c
+++ b/drivers/usb/gadget/uvc_video.c
@@ -309,7 +309,7 @@ uvc_video_pump(struct uvc_video *video)
video->encode(req, video, buf);
 
/* Queue the USB request */
-   if ((ret = usb_ep_queue(video->ep, req, GFP_KERNEL)) < 0) {
+   if ((ret = usb_ep_queue(video->ep, req, GFP_ATOMIC)) < 0) {
printk(KERN_INFO "Failed to queue request (%d)\n", ret);
usb_ep_set_halt(video->ep);
spin_unlock_irqrestore(>queue.irqlock, flags);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] UVC: use GFP_ATOMIC under spin lock.

2012-11-19 Thread Cyril Roelandt
Found using the following semantic patch:
spml
@@
@@
spin_lock_irqsave(...);
... when != spin_unlock_irqrestore(...);
* GFP_KERNEL
/spml

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/usb/gadget/uvc_video.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/uvc_video.c b/drivers/usb/gadget/uvc_video.c
index b0e53a8..79b4132 100644
--- a/drivers/usb/gadget/uvc_video.c
+++ b/drivers/usb/gadget/uvc_video.c
@@ -309,7 +309,7 @@ uvc_video_pump(struct uvc_video *video)
video-encode(req, video, buf);
 
/* Queue the USB request */
-   if ((ret = usb_ep_queue(video-ep, req, GFP_KERNEL))  0) {
+   if ((ret = usb_ep_queue(video-ep, req, GFP_ATOMIC))  0) {
printk(KERN_INFO Failed to queue request (%d)\n, ret);
usb_ep_set_halt(video-ep);
spin_unlock_irqrestore(video-queue.irqlock, flags);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mx2_camera: use GFP_ATOMIC under spin lock.

2012-11-19 Thread Cyril Roelandt
Found using the following semantic patch:

spml
@@
@@
spin_lock_irqsave(...);
... when != spin_unlock_irqrestore(...);
* GFP_KERNEL
/spml

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/media/platform/soc_camera/mx2_camera.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/mx2_camera.c 
b/drivers/media/platform/soc_camera/mx2_camera.c
index e575ae8..516b3a3 100644
--- a/drivers/media/platform/soc_camera/mx2_camera.c
+++ b/drivers/media/platform/soc_camera/mx2_camera.c
@@ -909,7 +909,7 @@ static int mx2_start_streaming(struct vb2_queue *q, 
unsigned int count)
pcdev-discard_size = icd-user_height * bytesperline;
pcdev-discard_buffer = dma_alloc_coherent(ici-v4l2_dev.dev,
pcdev-discard_size, pcdev-discard_buffer_dma,
-   GFP_KERNEL);
+   GFP_ATOMIC);
if (!pcdev-discard_buffer)
return -ENOMEM;
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] acpi_system_write_wakeup_device(): fix error check for unsigned variable.

2012-11-16 Thread Cyril Roelandt
The LEN variable is unsigned, therefore checking whether it is less than 0 is
useless.

Signed-off-by: Cyril Roelandt 
---
 drivers/acpi/proc.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index 27adb09..37871a7 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -366,8 +366,6 @@ acpi_system_write_wakeup_device(struct file *file,
 
if (len > 4)
len = 4;
-   if (len < 0)
-   return -EFAULT;
 
if (copy_from_user(strbuf, buffer, len))
return -EFAULT;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging/media/solo6x10/v4l2-enc.c: fix error-handling.

2012-11-16 Thread Cyril Roelandt
The return values of copy_to_user() and copy_from_user() cannot be negative.

Found using the following semantich patch:


@exists@
identifier ret;
statement S;
expression E;
@@
(
* ret = copy_to_user(...);
|
* ret = copy_from_user(...);
)
... when != ret = E
when != if (ret) { <+... ret = E; ...+> }
* if (ret < 0)
  S


Signed-off-by: Cyril Roelandt 
---
 drivers/staging/media/solo6x10/v4l2-enc.c |4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/media/solo6x10/v4l2-enc.c 
b/drivers/staging/media/solo6x10/v4l2-enc.c
index f8f0da9..4977e86 100644
--- a/drivers/staging/media/solo6x10/v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/v4l2-enc.c
@@ -1619,6 +1619,8 @@ static int solo_s_ext_ctrls(struct file *file, void *priv,
solo_enc->osd_text[OSD_TEXT_MAX] = '\0';
if (!err)
err = solo_osd_print(solo_enc);
+   else
+   err = -EFAULT;
}
break;
default:
@@ -1654,6 +1656,8 @@ static int solo_g_ext_ctrls(struct file *file, void *priv,
err = copy_to_user(ctrl->string,
   solo_enc->osd_text,
   OSD_TEXT_MAX);
+   if (err)
+   err = -EFAULT;
}
break;
default:
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging/media/solo6x10/v4l2-enc.c: fix error-handling.

2012-11-16 Thread Cyril Roelandt
The return values of copy_to_user() and copy_from_user() cannot be negative.

Found using the following semantich patch:

spml
@exists@
identifier ret;
statement S;
expression E;
@@
(
* ret = copy_to_user(...);
|
* ret = copy_from_user(...);
)
... when != ret = E
when != if (ret) { +... ret = E; ...+ }
* if (ret  0)
  S
/spml

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/staging/media/solo6x10/v4l2-enc.c |4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/media/solo6x10/v4l2-enc.c 
b/drivers/staging/media/solo6x10/v4l2-enc.c
index f8f0da9..4977e86 100644
--- a/drivers/staging/media/solo6x10/v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/v4l2-enc.c
@@ -1619,6 +1619,8 @@ static int solo_s_ext_ctrls(struct file *file, void *priv,
solo_enc-osd_text[OSD_TEXT_MAX] = '\0';
if (!err)
err = solo_osd_print(solo_enc);
+   else
+   err = -EFAULT;
}
break;
default:
@@ -1654,6 +1656,8 @@ static int solo_g_ext_ctrls(struct file *file, void *priv,
err = copy_to_user(ctrl-string,
   solo_enc-osd_text,
   OSD_TEXT_MAX);
+   if (err)
+   err = -EFAULT;
}
break;
default:
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] acpi_system_write_wakeup_device(): fix error check for unsigned variable.

2012-11-16 Thread Cyril Roelandt
The LEN variable is unsigned, therefore checking whether it is less than 0 is
useless.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/acpi/proc.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index 27adb09..37871a7 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -366,8 +366,6 @@ acpi_system_write_wakeup_device(struct file *file,
 
if (len  4)
len = 4;
-   if (len  0)
-   return -EFAULT;
 
if (copy_from_user(strbuf, buffer, len))
return -EFAULT;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] net/ethernet/intel/ixgbe/ixgbe_debugfs.c: fix error handling in ixgbe_dbg_reg_ops_read().

2012-11-15 Thread Cyril Roelandt
copy_to_user() cannot return a negative value: it returns the number of bytes
that could not be copied.

Return -EFAULT on failure rather than the number of bytes that could not be
copied, as this seems more standard.

Signed-off-by: Cyril Roelandt 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
index 8d3a218..77a3598 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
@@ -62,7 +62,6 @@ static ssize_t ixgbe_dbg_reg_ops_read(struct file *filp, char 
__user *buffer,
 {
struct ixgbe_adapter *adapter = filp->private_data;
char buf[256];
-   int bytes_not_copied;
int len;
 
/* don't allow partial reads */
@@ -73,9 +72,8 @@ static ssize_t ixgbe_dbg_reg_ops_read(struct file *filp, char 
__user *buffer,
   adapter->netdev->name, ixgbe_dbg_reg_ops_buf);
if (count < len)
return -ENOSPC;
-   bytes_not_copied = copy_to_user(buffer, buf, len);
-   if (bytes_not_copied < 0)
-   return bytes_not_copied;
+   if (copy_to_user(buffer, buf, len) > 0)
+   return -EFAULT;
 
*ppos = len;
return len;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] net/ethernet/intel/ixgbe/ixgbe_debugfs.c: fix error handling in ixgbe_dbg_reg_ops_read().

2012-11-15 Thread Cyril Roelandt
copy_to_user() cannot return a negative value: it returns the number of bytes
that could not be copied.

Return -EFAULT on failure rather than the number of bytes that could not be
copied, as this seems more standard.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
index 8d3a218..77a3598 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
@@ -62,7 +62,6 @@ static ssize_t ixgbe_dbg_reg_ops_read(struct file *filp, char 
__user *buffer,
 {
struct ixgbe_adapter *adapter = filp-private_data;
char buf[256];
-   int bytes_not_copied;
int len;
 
/* don't allow partial reads */
@@ -73,9 +72,8 @@ static ssize_t ixgbe_dbg_reg_ops_read(struct file *filp, char 
__user *buffer,
   adapter-netdev-name, ixgbe_dbg_reg_ops_buf);
if (count  len)
return -ENOSPC;
-   bytes_not_copied = copy_to_user(buffer, buf, len);
-   if (bytes_not_copied  0)
-   return bytes_not_copied;
+   if (copy_to_user(buffer, buf, len)  0)
+   return -EFAULT;
 
*ppos = len;
return len;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] Coccinelle: Add api/d_find_alias.cocci.

2012-11-11 Thread Cyril Roelandt
Ensure that calls to d_find_alias() have a corresponding dput().

Signed-off-by: Cyril Roelandt 
---
 scripts/coccinelle/api/d_find_alias.cocci |   80 +
 1 file changed, 80 insertions(+)
 create mode 100644 scripts/coccinelle/api/d_find_alias.cocci

diff --git a/scripts/coccinelle/api/d_find_alias.cocci 
b/scripts/coccinelle/api/d_find_alias.cocci
new file mode 100644
index 000..639eec7
--- /dev/null
+++ b/scripts/coccinelle/api/d_find_alias.cocci
@@ -0,0 +1,80 @@
+/// Make sure calls to d_find_alias() have a corresponding call to dput().
+//
+// Keywords: d_find_alias, dput
+//
+// Confidence: Moderate
+// URL: http://coccinelle.lip6.fr/
+// Options: -include_headers
+
+virtual context
+virtual org
+virtual patch
+virtual report
+
+@r exists@
+local idexpression struct dentry *dent;
+expression E, E1;
+statement S1, S2;
+position p1, p2;
+@@
+(
+   if (!(dent@p1 = d_find_alias(...))) S1
+|
+   dent@p1 = d_find_alias(...)
+)
+
+<...when != dput(dent)
+when != if (...) { <+... dput(dent) ...+> }
+when != true !dent || ...
+when != dent = E
+when != E = dent
+if (!dent || ...) S2
+...>
+(
+   return <+...dent...+>;
+|
+   return @p2 ...;
+|
+   dent@p2 = E1;
+|
+   E1 = dent;
+)
+
+@depends on context@
+local idexpression struct dentry *r.dent;
+position r.p1,r.p2;
+@@
+* dent@p1 = ...
+  ...
+(
+* return@p2 ...;
+|
+* dent@p2
+)
+
+
+@script:python depends on org@
+p1 << r.p1;
+p2 << r.p2;
+@@
+cocci.print_main("Missing call to dput()",p1)
+cocci.print_secs("",p2)
+
+@depends on patch@
+local idexpression struct dentry *r.dent;
+position r.p2;
+@@
+(
++ dput(dent);
+  return @p2 ...;
+|
++ dput(dent);
+  dent@p2 = ...;
+)
+
+@script:python depends on report@
+p1 << r.p1;
+p2 << r.p2;
+@@
+msg = "Missing call to dput() at line %s."
+coccilib.report.print_report(p1[0], msg % (p2[0].line))
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] iommu/tegra-smmu.c: fix dentry reference leak in smmu_debugfs_stats_show().

2012-11-11 Thread Cyril Roelandt
Call to d_find_alias() needs a corresponding dput().

Signed-off-by: Cyril Roelandt 
---
 drivers/iommu/tegra-smmu.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index 4167863..4252d74 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -1052,6 +1052,7 @@ static int smmu_debugfs_stats_show(struct seq_file *s, 
void *v)
stats[i], val, offs);
}
seq_printf(s, "\n");
+   dput(dent);
 
return 0;
 }
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] ceph: fix dentry reference leak in ceph_encode_fh().

2012-11-11 Thread Cyril Roelandt
dput() was not called in the error path.

Signed-off-by: Cyril Roelandt 
---
 fs/ceph/export.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/ceph/export.c b/fs/ceph/export.c
index 9349bb3..ca3ab3f 100644
--- a/fs/ceph/export.c
+++ b/fs/ceph/export.c
@@ -56,13 +56,15 @@ static int ceph_encode_fh(struct inode *inode, u32 *rawfh, 
int *max_len,
struct ceph_nfs_confh *cfh = (void *)rawfh;
int connected_handle_length = sizeof(*cfh)/4;
int handle_length = sizeof(*fh)/4;
-   struct dentry *dentry = d_find_alias(inode);
+   struct dentry *dentry;
struct dentry *parent;
 
/* don't re-export snaps */
if (ceph_snap(inode) != CEPH_NOSNAP)
return -EINVAL;
 
+   dentry = d_find_alias(inode);
+
/* if we found an alias, generate a connectable fh */
if (*max_len >= connected_handle_length && dentry) {
dout("encode_fh %p connectable\n", dentry);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] Use dput() after d_find_alias().

2012-11-11 Thread Cyril Roelandt
Hello,

A call to d_find_alias() needs a corresponding call to dput() in order to avoid
resource leaks.

The first patch is a Coccinelle scripts that looks for missing calls to dput().
The other two patches add calls to dput() where needed.

WBR,
Cyril Roelandt.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] Use dput() after d_find_alias().

2012-11-11 Thread Cyril Roelandt
Hello,

A call to d_find_alias() needs a corresponding call to dput() in order to avoid
resource leaks.

The first patch is a Coccinelle scripts that looks for missing calls to dput().
The other two patches add calls to dput() where needed.

WBR,
Cyril Roelandt.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] ceph: fix dentry reference leak in ceph_encode_fh().

2012-11-11 Thread Cyril Roelandt
dput() was not called in the error path.

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 fs/ceph/export.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/ceph/export.c b/fs/ceph/export.c
index 9349bb3..ca3ab3f 100644
--- a/fs/ceph/export.c
+++ b/fs/ceph/export.c
@@ -56,13 +56,15 @@ static int ceph_encode_fh(struct inode *inode, u32 *rawfh, 
int *max_len,
struct ceph_nfs_confh *cfh = (void *)rawfh;
int connected_handle_length = sizeof(*cfh)/4;
int handle_length = sizeof(*fh)/4;
-   struct dentry *dentry = d_find_alias(inode);
+   struct dentry *dentry;
struct dentry *parent;
 
/* don't re-export snaps */
if (ceph_snap(inode) != CEPH_NOSNAP)
return -EINVAL;
 
+   dentry = d_find_alias(inode);
+
/* if we found an alias, generate a connectable fh */
if (*max_len = connected_handle_length  dentry) {
dout(encode_fh %p connectable\n, dentry);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] iommu/tegra-smmu.c: fix dentry reference leak in smmu_debugfs_stats_show().

2012-11-11 Thread Cyril Roelandt
Call to d_find_alias() needs a corresponding dput().

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/iommu/tegra-smmu.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index 4167863..4252d74 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -1052,6 +1052,7 @@ static int smmu_debugfs_stats_show(struct seq_file *s, 
void *v)
stats[i], val, offs);
}
seq_printf(s, \n);
+   dput(dent);
 
return 0;
 }
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] Coccinelle: Add api/d_find_alias.cocci.

2012-11-11 Thread Cyril Roelandt
Ensure that calls to d_find_alias() have a corresponding dput().

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 scripts/coccinelle/api/d_find_alias.cocci |   80 +
 1 file changed, 80 insertions(+)
 create mode 100644 scripts/coccinelle/api/d_find_alias.cocci

diff --git a/scripts/coccinelle/api/d_find_alias.cocci 
b/scripts/coccinelle/api/d_find_alias.cocci
new file mode 100644
index 000..639eec7
--- /dev/null
+++ b/scripts/coccinelle/api/d_find_alias.cocci
@@ -0,0 +1,80 @@
+/// Make sure calls to d_find_alias() have a corresponding call to dput().
+//
+// Keywords: d_find_alias, dput
+//
+// Confidence: Moderate
+// URL: http://coccinelle.lip6.fr/
+// Options: -include_headers
+
+virtual context
+virtual org
+virtual patch
+virtual report
+
+@r exists@
+local idexpression struct dentry *dent;
+expression E, E1;
+statement S1, S2;
+position p1, p2;
+@@
+(
+   if (!(dent@p1 = d_find_alias(...))) S1
+|
+   dent@p1 = d_find_alias(...)
+)
+
+...when != dput(dent)
+when != if (...) { +... dput(dent) ...+ }
+when != true !dent || ...
+when != dent = E
+when != E = dent
+if (!dent || ...) S2
+...
+(
+   return +...dent...+;
+|
+   return @p2 ...;
+|
+   dent@p2 = E1;
+|
+   E1 = dent;
+)
+
+@depends on context@
+local idexpression struct dentry *r.dent;
+position r.p1,r.p2;
+@@
+* dent@p1 = ...
+  ...
+(
+* return@p2 ...;
+|
+* dent@p2
+)
+
+
+@script:python depends on org@
+p1  r.p1;
+p2  r.p2;
+@@
+cocci.print_main(Missing call to dput(),p1)
+cocci.print_secs(,p2)
+
+@depends on patch@
+local idexpression struct dentry *r.dent;
+position r.p2;
+@@
+(
++ dput(dent);
+  return @p2 ...;
+|
++ dput(dent);
+  dent@p2 = ...;
+)
+
+@script:python depends on report@
+p1  r.p1;
+p2  r.p2;
+@@
+msg = Missing call to dput() at line %s.
+coccilib.report.print_report(p1[0], msg % (p2[0].line))
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/