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>
This commit is contained in:
parent
d303b7c5b2
commit
2d3da59ff1
|
@ -74,7 +74,7 @@ int cypress_load_firmware(struct usb_device *udev,
|
|||
struct hexline *hx;
|
||||
int ret, pos = 0;
|
||||
|
||||
hx = kmalloc(sizeof(struct hexline), GFP_KERNEL);
|
||||
hx = kmalloc(sizeof(*hx), GFP_KERNEL);
|
||||
if (!hx)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -447,7 +447,7 @@ static struct smscore_registry_entry_t *smscore_find_registry(char *devpath)
|
|||
return entry;
|
||||
}
|
||||
}
|
||||
entry = kmalloc(sizeof(struct smscore_registry_entry_t), GFP_KERNEL);
|
||||
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
|
||||
if (entry) {
|
||||
entry->mode = default_mode;
|
||||
strcpy(entry->devpath, devpath);
|
||||
|
@ -536,9 +536,7 @@ int smscore_register_hotplug(hotplug_t hotplug)
|
|||
int rc = 0;
|
||||
|
||||
kmutex_lock(&g_smscore_deviceslock);
|
||||
|
||||
notifyee = kmalloc(sizeof(struct smscore_device_notifyee_t),
|
||||
GFP_KERNEL);
|
||||
notifyee = kmalloc(sizeof(*notifyee), GFP_KERNEL);
|
||||
if (notifyee) {
|
||||
/* now notify callback about existing devices */
|
||||
first = &g_smscore_devices;
|
||||
|
@ -627,7 +625,7 @@ smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer,
|
|||
{
|
||||
struct smscore_buffer_t *cb;
|
||||
|
||||
cb = kzalloc(sizeof(struct smscore_buffer_t), GFP_KERNEL);
|
||||
cb = kzalloc(sizeof(*cb), GFP_KERNEL);
|
||||
if (!cb)
|
||||
return NULL;
|
||||
|
||||
|
@ -655,7 +653,7 @@ int smscore_register_device(struct smsdevice_params_t *params,
|
|||
struct smscore_device_t *dev;
|
||||
u8 *buffer;
|
||||
|
||||
dev = kzalloc(sizeof(struct smscore_device_t), GFP_KERNEL);
|
||||
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
|
||||
if (!dev)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -1684,7 +1682,7 @@ static int smscore_validate_client(struct smscore_device_t *coredev,
|
|||
pr_err("The msg ID already registered to another client.\n");
|
||||
return -EEXIST;
|
||||
}
|
||||
listentry = kzalloc(sizeof(struct smscore_idlist_t), GFP_KERNEL);
|
||||
listentry = kzalloc(sizeof(*listentry), GFP_KERNEL);
|
||||
if (!listentry)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -1721,7 +1719,7 @@ int smscore_register_client(struct smscore_device_t *coredev,
|
|||
return -EEXIST;
|
||||
}
|
||||
|
||||
newclient = kzalloc(sizeof(struct smscore_client_t), GFP_KERNEL);
|
||||
newclient = kzalloc(sizeof(*newclient), GFP_KERNEL);
|
||||
if (!newclient)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -455,7 +455,7 @@ struct dvb_frontend *as102_attach(const char *name,
|
|||
struct as102_state *state;
|
||||
struct dvb_frontend *fe;
|
||||
|
||||
state = kzalloc(sizeof(struct as102_state), GFP_KERNEL);
|
||||
state = kzalloc(sizeof(*state), GFP_KERNEL);
|
||||
if (!state)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -552,8 +552,7 @@ struct dvb_frontend *cx24113_attach(struct dvb_frontend *fe,
|
|||
const struct cx24113_config *config, struct i2c_adapter *i2c)
|
||||
{
|
||||
/* allocate memory for the internal state */
|
||||
struct cx24113_state *state =
|
||||
kzalloc(sizeof(struct cx24113_state), GFP_KERNEL);
|
||||
struct cx24113_state *state = kzalloc(sizeof(*state), GFP_KERNEL);
|
||||
int rc;
|
||||
|
||||
if (!state)
|
||||
|
|
|
@ -1126,7 +1126,7 @@ struct dvb_frontend *cx24116_attach(const struct cx24116_config *config,
|
|||
dprintk("%s\n", __func__);
|
||||
|
||||
/* allocate memory for the internal state */
|
||||
state = kzalloc(sizeof(struct cx24116_state), GFP_KERNEL);
|
||||
state = kzalloc(sizeof(*state), GFP_KERNEL);
|
||||
if (state == NULL)
|
||||
goto error1;
|
||||
|
||||
|
|
|
@ -839,7 +839,7 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config,
|
|||
dprintk("%s\n", __func__);
|
||||
|
||||
/* allocate memory for the internal state */
|
||||
state = kzalloc(sizeof(struct ds3000_state), GFP_KERNEL);
|
||||
state = kzalloc(sizeof(*state), GFP_KERNEL);
|
||||
if (!state)
|
||||
goto error2;
|
||||
|
||||
|
|
|
@ -2071,7 +2071,7 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,
|
|||
dev_dbg(&i2c->dev, "%s called.\n", __func__);
|
||||
|
||||
/* allocate memory for the internal state */
|
||||
state = kzalloc(sizeof(struct mb86a20s_state), GFP_KERNEL);
|
||||
state = kzalloc(sizeof(*state), GFP_KERNEL);
|
||||
if (!state)
|
||||
goto error;
|
||||
|
||||
|
|
|
@ -381,7 +381,7 @@ static int sp2_probe(struct i2c_client *client,
|
|||
|
||||
dev_dbg(&client->dev, "\n");
|
||||
|
||||
s = kzalloc(sizeof(struct sp2), GFP_KERNEL);
|
||||
s = kzalloc(sizeof(*s), GFP_KERNEL);
|
||||
if (!s) {
|
||||
ret = -ENOMEM;
|
||||
goto err;
|
||||
|
|
|
@ -3467,7 +3467,7 @@ static int adv7842_probe(struct i2c_client *client,
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
state = devm_kzalloc(&client->dev, sizeof(struct adv7842_state), GFP_KERNEL);
|
||||
state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
|
||||
if (!state)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -909,7 +909,7 @@ static int cx18_probe(struct pci_dev *pci_dev,
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
cx = kzalloc(sizeof(struct cx18), GFP_ATOMIC);
|
||||
cx = kzalloc(sizeof(*cx), GFP_ATOMIC);
|
||||
if (!cx)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ static int hopper_pci_probe(struct pci_dev *pdev,
|
|||
struct mantis_hwconfig *config;
|
||||
int err;
|
||||
|
||||
mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL);
|
||||
mantis = kzalloc(sizeof(*mantis), GFP_KERNEL);
|
||||
if (mantis == NULL) {
|
||||
err = -ENOMEM;
|
||||
goto fail0;
|
||||
|
|
|
@ -173,7 +173,7 @@ static int mantis_pci_probe(struct pci_dev *pdev,
|
|||
struct mantis_hwconfig *config;
|
||||
int err;
|
||||
|
||||
mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL);
|
||||
mantis = kzalloc(sizeof(*mantis), GFP_KERNEL);
|
||||
if (!mantis)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -260,7 +260,7 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
|
|||
|
||||
DEB_EE("\n");
|
||||
|
||||
hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL);
|
||||
hexium = kzalloc(sizeof(*hexium), GFP_KERNEL);
|
||||
if (!hexium)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ static int hexium_probe(struct saa7146_dev *dev)
|
|||
return -EFAULT;
|
||||
}
|
||||
|
||||
hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL);
|
||||
hexium = kzalloc(sizeof(*hexium), GFP_KERNEL);
|
||||
if (!hexium)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port,
|
|||
goto ret;
|
||||
}
|
||||
|
||||
buf = kzalloc(sizeof(struct saa7164_buffer), GFP_KERNEL);
|
||||
buf = kzalloc(sizeof(*buf), GFP_KERNEL);
|
||||
if (!buf)
|
||||
goto ret;
|
||||
|
||||
|
@ -281,7 +281,7 @@ struct saa7164_user_buffer *saa7164_buffer_alloc_user(struct saa7164_dev *dev,
|
|||
{
|
||||
struct saa7164_user_buffer *buf;
|
||||
|
||||
buf = kzalloc(sizeof(struct saa7164_user_buffer), GFP_KERNEL);
|
||||
buf = kzalloc(sizeof(*buf), GFP_KERNEL);
|
||||
if (!buf)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -1505,7 +1505,7 @@ static int isc_formats_init(struct isc_device *isc)
|
|||
|
||||
isc->num_user_formats = num_fmts;
|
||||
isc->user_formats = devm_kcalloc(isc->dev,
|
||||
num_fmts, sizeof(struct isc_format *),
|
||||
num_fmts, sizeof(*isc->user_formats),
|
||||
GFP_KERNEL);
|
||||
if (!isc->user_formats)
|
||||
return -ENOMEM;
|
||||
|
|
|
@ -1421,7 +1421,7 @@ static int zr364xx_probe(struct usb_interface *intf,
|
|||
le16_to_cpu(udev->descriptor.idVendor),
|
||||
le16_to_cpu(udev->descriptor.idProduct));
|
||||
|
||||
cam = kzalloc(sizeof(struct zr364xx_camera), GFP_KERNEL);
|
||||
cam = kzalloc(sizeof(*cam), GFP_KERNEL);
|
||||
if (!cam)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
Loading…
Reference in New Issue