Commit 0bebaa5f authored by Markus Elfring's avatar Markus Elfring Committed by Mauro Carvalho Chehab

[media] RedRat3: Use kcalloc() in two functions

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data types by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 6037b3ca
...@@ -588,7 +588,7 @@ static void redrat3_get_firmware_rev(struct redrat3_dev *rr3) ...@@ -588,7 +588,7 @@ static void redrat3_get_firmware_rev(struct redrat3_dev *rr3)
int rc = 0; int rc = 0;
char *buffer; char *buffer;
buffer = kzalloc(sizeof(char) * (RR3_FW_VERSION_LEN + 1), GFP_KERNEL); buffer = kcalloc(RR3_FW_VERSION_LEN + 1, sizeof(*buffer), GFP_KERNEL);
if (!buffer) { if (!buffer) {
dev_err(rr3->dev, "Memory allocation failure\n"); dev_err(rr3->dev, "Memory allocation failure\n");
return; return;
...@@ -780,7 +780,9 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf, ...@@ -780,7 +780,9 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf,
/* rr3 will disable rc detector on transmit */ /* rr3 will disable rc detector on transmit */
rr3->transmitting = true; rr3->transmitting = true;
sample_lens = kzalloc(sizeof(int) * RR3_DRIVER_MAXLENS, GFP_KERNEL); sample_lens = kcalloc(RR3_DRIVER_MAXLENS,
sizeof(*sample_lens),
GFP_KERNEL);
if (!sample_lens) { if (!sample_lens) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment