Re: [PATCH v2] Staging: zram: Fix variable dereferenced before check

2013-10-21 Thread Minchan Kim
On Sat, Oct 19, 2013 at 01:59:05PM -0700, Greg KH wrote:
 On Sat, Oct 19, 2013 at 10:01:42PM +0530, Rashika Kheria wrote:
  This patch fixes the following Smatch warning in zram_drv.c-
  ~/git/kernels/linux/drivers/staging/zram/zram_drv.c:663
  reset_store() warn: variable dereferenced before check 'bdev' (see line 652)
  ~/git/kernels/linux/drivers/staging/zram/zram_drv.c:899
  destroy_device() warn: variable dereferenced before check 'zram-disk' (see 
  line 896)
  
  Signed-off-by: Rashika Kheria rashika.khe...@gmail.com
 
 zram is messy, tricky, and I hate it.  Seriously, I which I had never
 taken it into the staging tree...
 
 Anyway, I want the existing zram developers/maintainers to review this
 patch before I can accept it, as I don't trust anything that is ever
 done in that code, especially as I don't test it :)
 
 Minchan, Jiang, Nitin, what do you think of the patch below?  Can I get
 your ack on it so that I can apply it?

Hello Greg,

I will review he send v3 again if anybody doesn't review it.
Hope that Jerome or someone could review because I'm in LinuxCon now and
totally fail to adjust time zone.
So, Please understand late reply.

Thanks.

 
 thanks,
 
 greg k-h
 
  ---
  
  This revision fixes the following issues of the previous revision-
  Incorrect Correction of Sparse Warning
  
   drivers/staging/zram/zram_drv.c |8 +++-
   1 file changed, 3 insertions(+), 5 deletions(-)
  
  diff --git a/drivers/staging/zram/zram_drv.c 
  b/drivers/staging/zram/zram_drv.c
  index 2c4ed52..a74108a 100644
  --- a/drivers/staging/zram/zram_drv.c
  +++ b/drivers/staging/zram/zram_drv.c
  @@ -660,8 +660,7 @@ static ssize_t reset_store(struct device *dev,
  return -EINVAL;
   
  /* Make sure all pending I/O is finished */
  -   if (bdev)
  -   fsync_bdev(bdev);
  +   fsync_bdev(bdev);
   
  zram_reset_device(zram, true);
  return len;
  @@ -893,10 +892,9 @@ out:
   
   static void destroy_device(struct zram *zram)
   {
  -   sysfs_remove_group(disk_to_dev(zram-disk)-kobj,
  -   zram_disk_attr_group);
  -
  if (zram-disk) {
  +   sysfs_remove_group(disk_to_dev(zram-disk)-kobj,
  +   zram_disk_attr_group);
  del_gendisk(zram-disk);
  put_disk(zram-disk);
  }
  -- 
  1.7.9.5
  
  -- 
  You received this message because you are subscribed to the Google Groups 
  opw-kernel group.
  To unsubscribe from this group and stop receiving emails from it, send an 
  email to opw-kernel+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/groups/opt_out.

-- 
Kind regards,
Minchan Kim
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [OPW kernel] Re: [PATCH v2] Staging: zram: Fix variable dereferenced before check

2013-10-20 Thread Josh Triplett
On Sat, Oct 19, 2013 at 01:59:05PM -0700, Greg KH wrote:
 On Sat, Oct 19, 2013 at 10:01:42PM +0530, Rashika Kheria wrote:
  This patch fixes the following Smatch warning in zram_drv.c-
  ~/git/kernels/linux/drivers/staging/zram/zram_drv.c:663
  reset_store() warn: variable dereferenced before check 'bdev' (see line 652)
  ~/git/kernels/linux/drivers/staging/zram/zram_drv.c:899
  destroy_device() warn: variable dereferenced before check 'zram-disk' (see 
  line 896)
  
  Signed-off-by: Rashika Kheria rashika.khe...@gmail.com
 
 zram is messy, tricky, and I hate it.  Seriously, I which I had never
 taken it into the staging tree...
 
 Anyway, I want the existing zram developers/maintainers to review this
 patch before I can accept it, as I don't trust anything that is ever
 done in that code, especially as I don't test it :)
 
 Minchan, Jiang, Nitin, what do you think of the patch below?  Can I get
 your ack on it so that I can apply it?

I think you actually want to review v3 of this patch, not v2.

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


Re: [PATCH v2] Staging: zram: Fix variable dereferenced before check

2013-10-19 Thread Greg KH
On Sat, Oct 19, 2013 at 10:01:42PM +0530, Rashika Kheria wrote:
 This patch fixes the following Smatch warning in zram_drv.c-
 ~/git/kernels/linux/drivers/staging/zram/zram_drv.c:663
 reset_store() warn: variable dereferenced before check 'bdev' (see line 652)
 ~/git/kernels/linux/drivers/staging/zram/zram_drv.c:899
 destroy_device() warn: variable dereferenced before check 'zram-disk' (see 
 line 896)
 
 Signed-off-by: Rashika Kheria rashika.khe...@gmail.com

zram is messy, tricky, and I hate it.  Seriously, I which I had never
taken it into the staging tree...

Anyway, I want the existing zram developers/maintainers to review this
patch before I can accept it, as I don't trust anything that is ever
done in that code, especially as I don't test it :)

Minchan, Jiang, Nitin, what do you think of the patch below?  Can I get
your ack on it so that I can apply it?

thanks,

greg k-h

 ---
 
 This revision fixes the following issues of the previous revision-
 Incorrect Correction of Sparse Warning
 
  drivers/staging/zram/zram_drv.c |8 +++-
  1 file changed, 3 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
 index 2c4ed52..a74108a 100644
 --- a/drivers/staging/zram/zram_drv.c
 +++ b/drivers/staging/zram/zram_drv.c
 @@ -660,8 +660,7 @@ static ssize_t reset_store(struct device *dev,
   return -EINVAL;
  
   /* Make sure all pending I/O is finished */
 - if (bdev)
 - fsync_bdev(bdev);
 + fsync_bdev(bdev);
  
   zram_reset_device(zram, true);
   return len;
 @@ -893,10 +892,9 @@ out:
  
  static void destroy_device(struct zram *zram)
  {
 - sysfs_remove_group(disk_to_dev(zram-disk)-kobj,
 - zram_disk_attr_group);
 -
   if (zram-disk) {
 + sysfs_remove_group(disk_to_dev(zram-disk)-kobj,
 + zram_disk_attr_group);
   del_gendisk(zram-disk);
   put_disk(zram-disk);
   }
 -- 
 1.7.9.5
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 opw-kernel group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to opw-kernel+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel