aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2017-08-28 05:55:16 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-09-23 08:20:57 -0400
commit2d3da59ff163b2aa805de0fc65ba933a735b00cd (patch)
tree4c370d1bf357c25d8941627ed8968ab295f1f8ee
parentd303b7c5b2660d93ba0dd2bf99b7dfa7bb93de73 (diff)
media: drivers: improve a size determination
Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. This issue was detected by using the Coccinelle software. [mchehab@s-opensoure.com: merge similar patches into one] Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Hans Verkuil <hansverk@cisco.com>
-rw-r--r--drivers/media/common/cypress_firmware.c2
-rw-r--r--drivers/media/common/siano/smscoreapi.c14
-rw-r--r--drivers/media/dvb-frontends/as102_fe.c2
-rw-r--r--drivers/media/dvb-frontends/cx24113.c3
-rw-r--r--drivers/media/dvb-frontends/cx24116.c2
-rw-r--r--drivers/media/dvb-frontends/ds3000.c2
-rw-r--r--drivers/media/dvb-frontends/mb86a20s.c2
-rw-r--r--drivers/media/dvb-frontends/sp2.c2
-rw-r--r--drivers/media/i2c/adv7842.c2
-rw-r--r--drivers/media/pci/cx18/cx18-driver.c2
-rw-r--r--drivers/media/pci/mantis/hopper_cards.c2
-rw-r--r--drivers/media/pci/mantis/mantis_cards.c2
-rw-r--r--drivers/media/pci/saa7146/hexium_gemini.c2
-rw-r--r--drivers/media/pci/saa7146/hexium_orion.c2
-rw-r--r--drivers/media/pci/saa7164/saa7164-buffer.c4
-rw-r--r--drivers/media/platform/atmel/atmel-isc.c2
-rw-r--r--drivers/media/usb/zr364xx/zr364xx.c2
17 files changed, 23 insertions, 26 deletions
diff --git a/drivers/media/common/cypress_firmware.c b/drivers/media/common/cypress_firmware.c
index bfe47bc5f716..8895158c1962 100644
--- a/drivers/media/common/cypress_firmware.c
+++ b/drivers/media/common/cypress_firmware.c
@@ -74,7 +74,7 @@ int cypress_load_firmware(struct usb_device *udev,
74 struct hexline *hx; 74 struct hexline *hx;
75 int ret, pos = 0; 75 int ret, pos = 0;
76 76
77 hx = kmalloc(sizeof(struct hexline), GFP_KERNEL); 77 hx = kmalloc(sizeof(*hx), GFP_KERNEL);
78 if (!hx) 78 if (!hx)
79 return -ENOMEM; 79 return -ENOMEM;
80 80
diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c
index 889b486fbc72..ad1c41f727b1 100644
--- a/drivers/media/common/siano/smscoreapi.c
+++ b/drivers/media/common/siano/smscoreapi.c
@@ -447,7 +447,7 @@ static struct smscore_registry_entry_t *smscore_find_registry(char *devpath)
447 return entry; 447 return entry;
448 } 448 }
449 } 449 }
450 entry = kmalloc(sizeof(struct smscore_registry_entry_t), GFP_KERNEL); 450 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
451 if (entry) { 451 if (entry) {
452 entry->mode = default_mode; 452 entry->mode = default_mode;
453 strcpy(entry->devpath, devpath); 453 strcpy(entry->devpath, devpath);
@@ -536,9 +536,7 @@ int smscore_register_hotplug(hotplug_t hotplug)
536 int rc = 0; 536 int rc = 0;
537 537
538 kmutex_lock(&g_smscore_deviceslock); 538 kmutex_lock(&g_smscore_deviceslock);
539 539 notifyee = kmalloc(sizeof(*notifyee), GFP_KERNEL);
540 notifyee = kmalloc(sizeof(struct smscore_device_notifyee_t),
541 GFP_KERNEL);
542 if (notifyee) { 540 if (notifyee) {
543 /* now notify callback about existing devices */ 541 /* now notify callback about existing devices */
544 first = &g_smscore_devices; 542 first = &g_smscore_devices;
@@ -627,7 +625,7 @@ smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer,
627{ 625{
628 struct smscore_buffer_t *cb; 626 struct smscore_buffer_t *cb;
629 627
630 cb = kzalloc(sizeof(struct smscore_buffer_t), GFP_KERNEL); 628 cb = kzalloc(sizeof(*cb), GFP_KERNEL);
631 if (!cb) 629 if (!cb)
632 return NULL; 630 return NULL;
633 631
@@ -655,7 +653,7 @@ int smscore_register_device(struct smsdevice_params_t *params,
655 struct smscore_device_t *dev; 653 struct smscore_device_t *dev;
656 u8 *buffer; 654 u8 *buffer;
657 655
658 dev = kzalloc(sizeof(struct smscore_device_t), GFP_KERNEL); 656 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
659 if (!dev) 657 if (!dev)
660 return -ENOMEM; 658 return -ENOMEM;
661 659
@@ -1684,7 +1682,7 @@ static int smscore_validate_client(struct smscore_device_t *coredev,
1684 pr_err("The msg ID already registered to another client.\n"); 1682 pr_err("The msg ID already registered to another client.\n");
1685 return -EEXIST; 1683 return -EEXIST;
1686 } 1684 }
1687 listentry = kzalloc(sizeof(struct smscore_idlist_t), GFP_KERNEL); 1685 listentry = kzalloc(sizeof(*listentry), GFP_KERNEL);
1688 if (!listentry) 1686 if (!listentry)
1689 return -ENOMEM; 1687 return -ENOMEM;
1690 1688
@@ -1721,7 +1719,7 @@ int smscore_register_client(struct smscore_device_t *coredev,
1721 return -EEXIST; 1719 return -EEXIST;
1722 } 1720 }
1723 1721
1724 newclient = kzalloc(sizeof(struct smscore_client_t), GFP_KERNEL); 1722 newclient = kzalloc(sizeof(*newclient), GFP_KERNEL);
1725 if (!newclient) 1723 if (!newclient)
1726 return -ENOMEM; 1724 return -ENOMEM;
1727 1725
diff --git a/drivers/media/dvb-frontends/as102_fe.c b/drivers/media/dvb-frontends/as102_fe.c
index 1fb4ab21d786..b1c84ee914f0 100644
--- a/drivers/media/dvb-frontends/as102_fe.c
+++ b/drivers/media/dvb-frontends/as102_fe.c
@@ -455,7 +455,7 @@ struct dvb_frontend *as102_attach(const char *name,
455 struct as102_state *state; 455 struct as102_state *state;
456 struct dvb_frontend *fe; 456 struct dvb_frontend *fe;
457 457
458 state = kzalloc(sizeof(struct as102_state), GFP_KERNEL); 458 state = kzalloc(sizeof(*state), GFP_KERNEL);
459 if (!state) 459 if (!state)
460 return NULL; 460 return NULL;
461 461
diff --git a/drivers/media/dvb-frontends/cx24113.c b/drivers/media/dvb-frontends/cx24113.c
index 8fc7333c76b7..2c5502cab5e1 100644
--- a/drivers/media/dvb-frontends/cx24113.c
+++ b/drivers/media/dvb-frontends/cx24113.c
@@ -552,8 +552,7 @@ struct dvb_frontend *cx24113_attach(struct dvb_frontend *fe,
552 const struct cx24113_config *config, struct i2c_adapter *i2c) 552 const struct cx24113_config *config, struct i2c_adapter *i2c)
553{ 553{
554 /* allocate memory for the internal state */ 554 /* allocate memory for the internal state */
555 struct cx24113_state *state = 555 struct cx24113_state *state = kzalloc(sizeof(*state), GFP_KERNEL);
556 kzalloc(sizeof(struct cx24113_state), GFP_KERNEL);
557 int rc; 556 int rc;
558 557
559 if (!state) 558 if (!state)
diff --git a/drivers/media/dvb-frontends/cx24116.c b/drivers/media/dvb-frontends/cx24116.c
index e5135fbe0297..531c5861a27e 100644
--- a/drivers/media/dvb-frontends/cx24116.c
+++ b/drivers/media/dvb-frontends/cx24116.c
@@ -1126,7 +1126,7 @@ struct dvb_frontend *cx24116_attach(const struct cx24116_config *config,
1126 dprintk("%s\n", __func__); 1126 dprintk("%s\n", __func__);
1127 1127
1128 /* allocate memory for the internal state */ 1128 /* allocate memory for the internal state */
1129 state = kzalloc(sizeof(struct cx24116_state), GFP_KERNEL); 1129 state = kzalloc(sizeof(*state), GFP_KERNEL);
1130 if (state == NULL) 1130 if (state == NULL)
1131 goto error1; 1131 goto error1;
1132 1132
diff --git a/drivers/media/dvb-frontends/ds3000.c b/drivers/media/dvb-frontends/ds3000.c
index 293c4103e5ff..3e347d03acb3 100644
--- a/drivers/media/dvb-frontends/ds3000.c
+++ b/drivers/media/dvb-frontends/ds3000.c
@@ -839,7 +839,7 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config,
839 dprintk("%s\n", __func__); 839 dprintk("%s\n", __func__);
840 840
841 /* allocate memory for the internal state */ 841 /* allocate memory for the internal state */
842 state = kzalloc(sizeof(struct ds3000_state), GFP_KERNEL); 842 state = kzalloc(sizeof(*state), GFP_KERNEL);
843 if (!state) 843 if (!state)
844 goto error2; 844 goto error2;
845 845
diff --git a/drivers/media/dvb-frontends/mb86a20s.c b/drivers/media/dvb-frontends/mb86a20s.c
index 340984100aec..ba7a433dd424 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -2071,7 +2071,7 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,
2071 dev_dbg(&i2c->dev, "%s called.\n", __func__); 2071 dev_dbg(&i2c->dev, "%s called.\n", __func__);
2072 2072
2073 /* allocate memory for the internal state */ 2073 /* allocate memory for the internal state */
2074 state = kzalloc(sizeof(struct mb86a20s_state), GFP_KERNEL); 2074 state = kzalloc(sizeof(*state), GFP_KERNEL);
2075 if (!state) 2075 if (!state)
2076 goto error; 2076 goto error;
2077 2077
diff --git a/drivers/media/dvb-frontends/sp2.c b/drivers/media/dvb-frontends/sp2.c
index d3b4f8822096..dd556012ceb6 100644
--- a/drivers/media/dvb-frontends/sp2.c
+++ b/drivers/media/dvb-frontends/sp2.c
@@ -381,7 +381,7 @@ static int sp2_probe(struct i2c_client *client,
381 381
382 dev_dbg(&client->dev, "\n"); 382 dev_dbg(&client->dev, "\n");
383 383
384 s = kzalloc(sizeof(struct sp2), GFP_KERNEL); 384 s = kzalloc(sizeof(*s), GFP_KERNEL);
385 if (!s) { 385 if (!s) {
386 ret = -ENOMEM; 386 ret = -ENOMEM;
387 goto err; 387 goto err;
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index c582bcb782a6..136aa80a834b 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -3467,7 +3467,7 @@ static int adv7842_probe(struct i2c_client *client,
3467 return -ENODEV; 3467 return -ENODEV;
3468 } 3468 }
3469 3469
3470 state = devm_kzalloc(&client->dev, sizeof(struct adv7842_state), GFP_KERNEL); 3470 state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
3471 if (!state) 3471 if (!state)
3472 return -ENOMEM; 3472 return -ENOMEM;
3473 3473
diff --git a/drivers/media/pci/cx18/cx18-driver.c b/drivers/media/pci/cx18/cx18-driver.c
index 9e99c6ef1476..6efa93168059 100644
--- a/drivers/media/pci/cx18/cx18-driver.c
+++ b/drivers/media/pci/cx18/cx18-driver.c
@@ -909,7 +909,7 @@ static int cx18_probe(struct pci_dev *pci_dev,
909 return -ENOMEM; 909 return -ENOMEM;
910 } 910 }
911 911
912 cx = kzalloc(sizeof(struct cx18), GFP_ATOMIC); 912 cx = kzalloc(sizeof(*cx), GFP_ATOMIC);
913 if (!cx) 913 if (!cx)
914 return -ENOMEM; 914 return -ENOMEM;
915 915
diff --git a/drivers/media/pci/mantis/hopper_cards.c b/drivers/media/pci/mantis/hopper_cards.c
index a96ac0144fd2..ecb97dc381fb 100644
--- a/drivers/media/pci/mantis/hopper_cards.c
+++ b/drivers/media/pci/mantis/hopper_cards.c
@@ -163,7 +163,7 @@ static int hopper_pci_probe(struct pci_dev *pdev,
163 struct mantis_hwconfig *config; 163 struct mantis_hwconfig *config;
164 int err; 164 int err;
165 165
166 mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL); 166 mantis = kzalloc(sizeof(*mantis), GFP_KERNEL);
167 if (mantis == NULL) { 167 if (mantis == NULL) {
168 err = -ENOMEM; 168 err = -ENOMEM;
169 goto fail0; 169 goto fail0;
diff --git a/drivers/media/pci/mantis/mantis_cards.c b/drivers/media/pci/mantis/mantis_cards.c
index 9958b6f4405f..4ce8a90d69dc 100644
--- a/drivers/media/pci/mantis/mantis_cards.c
+++ b/drivers/media/pci/mantis/mantis_cards.c
@@ -173,7 +173,7 @@ static int mantis_pci_probe(struct pci_dev *pdev,
173 struct mantis_hwconfig *config; 173 struct mantis_hwconfig *config;
174 int err; 174 int err;
175 175
176 mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL); 176 mantis = kzalloc(sizeof(*mantis), GFP_KERNEL);
177 if (!mantis) 177 if (!mantis)
178 return -ENOMEM; 178 return -ENOMEM;
179 179
diff --git a/drivers/media/pci/saa7146/hexium_gemini.c b/drivers/media/pci/saa7146/hexium_gemini.c
index 32c19bad9a17..d31a2d4494d1 100644
--- a/drivers/media/pci/saa7146/hexium_gemini.c
+++ b/drivers/media/pci/saa7146/hexium_gemini.c
@@ -260,7 +260,7 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
260 260
261 DEB_EE("\n"); 261 DEB_EE("\n");
262 262
263 hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL); 263 hexium = kzalloc(sizeof(*hexium), GFP_KERNEL);
264 if (!hexium) 264 if (!hexium)
265 return -ENOMEM; 265 return -ENOMEM;
266 266
diff --git a/drivers/media/pci/saa7146/hexium_orion.c b/drivers/media/pci/saa7146/hexium_orion.c
index 8d1dc8eea988..7dc182202f8b 100644
--- a/drivers/media/pci/saa7146/hexium_orion.c
+++ b/drivers/media/pci/saa7146/hexium_orion.c
@@ -219,7 +219,7 @@ static int hexium_probe(struct saa7146_dev *dev)
219 return -EFAULT; 219 return -EFAULT;
220 } 220 }
221 221
222 hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL); 222 hexium = kzalloc(sizeof(*hexium), GFP_KERNEL);
223 if (!hexium) 223 if (!hexium)
224 return -ENOMEM; 224 return -ENOMEM;
225 225
diff --git a/drivers/media/pci/saa7164/saa7164-buffer.c b/drivers/media/pci/saa7164/saa7164-buffer.c
index 6bd665ea190d..c83b2e914dcb 100644
--- a/drivers/media/pci/saa7164/saa7164-buffer.c
+++ b/drivers/media/pci/saa7164/saa7164-buffer.c
@@ -98,7 +98,7 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port,
98 goto ret; 98 goto ret;
99 } 99 }
100 100
101 buf = kzalloc(sizeof(struct saa7164_buffer), GFP_KERNEL); 101 buf = kzalloc(sizeof(*buf), GFP_KERNEL);
102 if (!buf) 102 if (!buf)
103 goto ret; 103 goto ret;
104 104
@@ -281,7 +281,7 @@ struct saa7164_user_buffer *saa7164_buffer_alloc_user(struct saa7164_dev *dev,
281{ 281{
282 struct saa7164_user_buffer *buf; 282 struct saa7164_user_buffer *buf;
283 283
284 buf = kzalloc(sizeof(struct saa7164_user_buffer), GFP_KERNEL); 284 buf = kzalloc(sizeof(*buf), GFP_KERNEL);
285 if (!buf) 285 if (!buf)
286 return NULL; 286 return NULL;
287 287
diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c
index db410c558a74..755d2d4dd142 100644
--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -1505,7 +1505,7 @@ static int isc_formats_init(struct isc_device *isc)
1505 1505
1506 isc->num_user_formats = num_fmts; 1506 isc->num_user_formats = num_fmts;
1507 isc->user_formats = devm_kcalloc(isc->dev, 1507 isc->user_formats = devm_kcalloc(isc->dev,
1508 num_fmts, sizeof(struct isc_format *), 1508 num_fmts, sizeof(*isc->user_formats),
1509 GFP_KERNEL); 1509 GFP_KERNEL);
1510 if (!isc->user_formats) 1510 if (!isc->user_formats)
1511 return -ENOMEM; 1511 return -ENOMEM;
diff --git a/drivers/media/usb/zr364xx/zr364xx.c b/drivers/media/usb/zr364xx/zr364xx.c
index b50cff4ef9eb..b3d05027bd9a 100644
--- a/drivers/media/usb/zr364xx/zr364xx.c
+++ b/drivers/media/usb/zr364xx/zr364xx.c
@@ -1421,7 +1421,7 @@ static int zr364xx_probe(struct usb_interface *intf,
1421 le16_to_cpu(udev->descriptor.idVendor), 1421 le16_to_cpu(udev->descriptor.idVendor),
1422 le16_to_cpu(udev->descriptor.idProduct)); 1422 le16_to_cpu(udev->descriptor.idProduct));
1423 1423
1424 cam = kzalloc(sizeof(struct zr364xx_camera), GFP_KERNEL); 1424 cam = kzalloc(sizeof(*cam), GFP_KERNEL);
1425 if (!cam) 1425 if (!cam)
1426 return -ENOMEM; 1426 return -ENOMEM;
1427 1427