Re: [PATCH 11/29] drivers, media: convert cx88_core.refcount from atomic_t to refcount_t

From
Sergei Shtylyov <hidden>
Date
2017-03-06 16:34:52
Also in
linux-bcache, linux-media, linux-pci, linux-raid, linux-s390, linux-scsi, linux-serial, lkml
Reply to
Elena Reshetova, 2017-03-06
Hello.

On 03/06/2017 05:20 PM, Elena Reshetova wrote:
refcount_t type and corresponding API should be
used instead of atomic_t when the variable is used as
a reference counter. This allows to avoid accidental
refcounter overflows that might lead to use-after-free
situations.

Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
Signed-off-by: Hans Liljestrand <redacted>
Signed-off-by: Kees Cook <redacted>
Signed-off-by: David Windsor <redacted>
[...]
quoted hunk ↗ jump to hunk
diff --git a/drivers/media/pci/cx88/cx88.h b/drivers/media/pci/cx88/cx88.h
index 115414c..16c1313 100644
--- a/drivers/media/pci/cx88/cx88.h
+++ b/drivers/media/pci/cx88/cx88.h
@@ -24,6 +24,7 @@
 #include <linux/i2c-algo-bit.h>
 #include <linux/videodev2.h>
 #include <linux/kdev_t.h>
+#include <linux/refcount.h>

 #include <media/v4l2-device.h>
 #include <media/v4l2-fh.h>
@@ -339,7 +340,7 @@ struct cx8802_dev;

 struct cx88_core {
 	struct list_head           devlist;
-	atomic_t                   refcount;
+	refcount_t                   refcount;
   Could you please keep the name aligned with above and below?
 	/* board name */
 	int                        nr;
MBR, Sergei
Thread (63 messages) 63 messages, 12 authors, last reply 2017-03-21
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help