From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-media@vger.kernel.org, Hans Verkuil <hverkuil@xs4all.nl>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Sean Young <sean@mess.org>,
Wolfram Sang <wsa-dev@sang-engineering.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org,
Julia Lawall <julia.lawall@lip6.fr>
Subject: [PATCH 04/18] [media] RedRat3: One function call less in redrat3_transmit_ir() after error detection
Date: Thu, 13 Oct 2016 18:24:46 +0200 [thread overview]
Message-ID: <7878868c-bc54-5577-b808-ed096bbf3759@users.sourceforge.net> (raw)
In-Reply-To: <81cef537-4ad0-3a74-8bde-94707dcd03f4@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 13 Oct 2016 10:50:24 +0200
The kfree() function was called in one case by the
redrat3_transmit_ir() function during error handling
even if the passed variable contained a null pointer.
* Adjust jump targets according to the Linux coding style convention.
* Move the resetting for the data structure member "transmitting"
at the end.
* Delete initialisations for the variables "irdata" and "sample_lens"
at the beginning which became unnecessary with this refactoring.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/rc/redrat3.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 7ae2ced..71e901d 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -723,10 +723,10 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf,
{
struct redrat3_dev *rr3 = rcdev->priv;
struct device *dev = rr3->dev;
- struct redrat3_irdata *irdata = NULL;
+ struct redrat3_irdata *irdata;
int ret, ret_len;
int lencheck, cur_sample_len, pipe;
- int *sample_lens = NULL;
+ int *sample_lens;
u8 curlencheck;
unsigned i, sendbuf_len;
@@ -747,7 +747,7 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf,
irdata = kzalloc(sizeof(*irdata), GFP_KERNEL);
if (!irdata) {
ret = -ENOMEM;
- goto out;
+ goto free_sample;
}
/* rr3 will disable rc detector on transmit */
@@ -776,7 +776,7 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf,
curlencheck++;
} else {
ret = -EINVAL;
- goto out;
+ goto reset_member;
}
}
irdata->sigdata[i] = lencheck;
@@ -811,14 +811,12 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf,
dev_err(dev, "Error: control msg send failed, rc %d\n", ret);
else
ret = count;
-
-out:
- kfree(irdata);
- kfree(sample_lens);
-
+reset_member:
rr3->transmitting = false;
/* rr3 re-enables rc detector because it was enabled before */
-
+ kfree(irdata);
+free_sample:
+ kfree(sample_lens);
return ret;
}
--
2.10.1
next prev parent reply other threads:[~2016-10-13 16:25 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <566ABCD9.1060404@users.sourceforge.net>
2015-12-27 17:33 ` [PATCH] [media] si2165: Refactoring for si2165_writereg_mask8() SF Markus Elfring
2016-01-04 8:39 ` Matthias Schwarzott
2015-12-27 21:22 ` [PATCH] [media] bttv: Returning only value constants in two functions SF Markus Elfring
2015-12-28 9:15 ` [PATCH] [media] tuners: One check less in m88rs6000t_get_rf_strength() after error detection SF Markus Elfring
2015-12-28 9:20 ` Julia Lawall
2015-12-28 10:30 ` SF Markus Elfring
2015-12-28 10:36 ` Julia Lawall
2015-12-28 14:36 ` [PATCH 0/2] [media] m88rs6000t: Fine-tuning for some function implementations SF Markus Elfring
2015-12-28 14:38 ` [PATCH 1/2] [media] m88rs6000t: Better exception handling in five functions SF Markus Elfring
2015-12-28 14:42 ` Julia Lawall
2015-12-28 15:03 ` SF Markus Elfring
2015-12-28 15:12 ` Julia Lawall
2016-01-25 17:01 ` [PATCH 1/2] " Mauro Carvalho Chehab
2016-01-25 18:15 ` SF Markus Elfring
2015-12-28 14:42 ` [PATCH 2/2] [media] tuners: Refactoring for m88rs6000t_sleep() SF Markus Elfring
2015-12-28 16:24 ` [PATCH 0/2] [media] r820t: Fine-tuning for generic_set_freq() SF Markus Elfring
2015-12-28 16:30 ` [PATCH 1/2] [media] r820t: Delete an unnecessary variable initialisation in generic_set_freq() SF Markus Elfring
2015-12-28 16:32 ` [PATCH 2/2] [media] r820t: Better exception handling " SF Markus Elfring
2016-01-25 17:04 ` Mauro Carvalho Chehab
2015-12-28 19:20 ` [PATCH] [media] xc5000: Faster result reporting in xc_load_fw_and_init_tuner() SF Markus Elfring
2016-01-25 17:06 ` Mauro Carvalho Chehab
2016-01-25 18:23 ` SF Markus Elfring
2016-01-25 18:38 ` Devin Heitmueller
2015-12-28 21:15 ` [PATCH] [media] airspy: Better exception handling in two functions SF Markus Elfring
2015-12-28 21:56 ` [PATCH] [media] au0828: Refactoring for start_urb_transfer() SF Markus Elfring
2015-12-29 10:18 ` [PATCH] [media] hdpvr: Refactoring for hdpvr_read() SF Markus Elfring
2015-12-29 11:37 ` [PATCH] [media] msi2500: Delete an unnecessary check in msi2500_set_usb_adc() SF Markus Elfring
2016-08-19 9:17 ` [PATCH 0/2] uvc_v4l2: Fine-tuning for uvc_ioctl_ctrl_map() SF Markus Elfring
2016-08-19 9:23 ` [PATCH 1/2] uvc_v4l2: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-11-22 17:21 ` Laurent Pinchart
2016-08-19 9:25 ` [PATCH 2/2] uvc_v4l2: One function call less in uvc_ioctl_ctrl_map() after error detection SF Markus Elfring
2016-10-07 19:43 ` [PATCH 0/2] [media] dvb-tc90522: Fine-tuning for two function implementations SF Markus Elfring
2016-10-07 19:45 ` [PATCH 1/2] [media] dvb-tc90522: Use kmalloc_array() in tc90522_master_xfer() SF Markus Elfring
2016-10-07 19:46 ` [PATCH 2/2] [media] dvb-tc90522: Rename a jump label in tc90522_probe() SF Markus Elfring
2016-10-08 11:57 ` walter harms
2016-10-13 16:15 ` [PATCH 00/18] [media] RedRat3: Fine-tuning for several function implementations SF Markus Elfring
2016-10-13 16:18 ` [PATCH 01/18] [media] RedRat3: Use kcalloc() in two functions SF Markus Elfring
2016-10-13 16:29 ` Joe Perches
2016-10-14 5:45 ` [media] RedRat3: Use kcalloc() in two functions? SF Markus Elfring
2016-10-13 16:20 ` [PATCH 02/18] [media] RedRat3: Move two assignments in redrat3_transmit_ir() SF Markus Elfring
2016-10-14 8:15 ` Dan Carpenter
2016-10-14 12:01 ` [media] RedRat3: Move two assignments in redrat3_transmit_ir()? SF Markus Elfring
2016-10-13 16:23 ` [PATCH 03/18] [media] RedRat3: Return directly after a failed kcalloc() in redrat3_transmit_ir() SF Markus Elfring
2016-10-13 16:24 ` SF Markus Elfring [this message]
2016-10-15 13:33 ` [PATCH 04/18] [media] RedRat3: One function call less in redrat3_transmit_ir() after error detection Sean Young
2016-10-15 17:00 ` SF Markus Elfring
2016-10-13 16:26 ` [PATCH 05/18] [media] RedRat3: Delete six messages for a failed memory allocation SF Markus Elfring
2016-10-13 16:27 ` [PATCH 06/18] [media] RedRat3: Delete an unnecessary variable initialisation in redrat3_get_firmware_rev() SF Markus Elfring
2016-10-13 16:28 ` [PATCH 07/18] [media] RedRat3: Improve another size determination in redrat3_reset() SF Markus Elfring
2016-10-13 16:29 ` [PATCH 08/18] [media] RedRat3: Improve another size determination in redrat3_send_cmd() SF Markus Elfring
2016-10-13 16:30 ` [PATCH 09/18] [media] RedRat3: Move a variable assignment in redrat3_dev_probe() SF Markus Elfring
2016-10-13 16:32 ` [PATCH 10/18] [media] RedRat3: Delete an unnecessary variable initialisation in redrat3_init_rc_dev() SF Markus Elfring
2016-10-13 16:33 ` [PATCH 11/18] [media] RedRat3: Delete the variable "dev" " SF Markus Elfring
2016-10-13 16:39 ` [PATCH 12/18] [media] RedRat3: Move a variable assignment " SF Markus Elfring
2016-10-13 21:38 ` Sean Young
2016-10-13 16:40 ` [PATCH 13/18] [media] RedRat3: Return directly after a failed rc_allocate_device() " SF Markus Elfring
2016-10-13 16:42 ` [PATCH 14/18] [media] RedRat3: Rename a jump label " SF Markus Elfring
2016-11-18 12:52 ` Mauro Carvalho Chehab
2016-11-18 13:00 ` Mauro Carvalho Chehab
2016-10-13 16:43 ` [PATCH 15/18] [media] RedRat3: Delete two variables in redrat3_set_timeout() SF Markus Elfring
2016-10-13 16:45 ` [PATCH 16/18] [media] RedRat3: Move a variable assignment " SF Markus Elfring
2016-10-13 16:47 ` [PATCH 17/18] [media] RedRat3: Adjust two checks for null pointers in redrat3_dev_probe() SF Markus Elfring
2016-10-13 16:48 ` [PATCH 18/18] [media] RedRat3: Combine substrings for six messages SF Markus Elfring
2016-10-14 11:40 ` [PATCH 0/5] [media] winbond-cir: Fine-tuning for four function implementations SF Markus Elfring
2016-10-14 11:41 ` [PATCH 1/5] [media] winbond-cir: Use kmalloc_array() in wbcir_tx() SF Markus Elfring
2016-10-14 11:42 ` [PATCH 2/5] [media] winbond-cir: Move a variable assignment " SF Markus Elfring
2016-10-14 11:43 ` [PATCH 3/5] [media] winbond-cir: Move assignments for three variables in wbcir_shutdown() SF Markus Elfring
2016-10-14 11:44 ` [PATCH 4/5] [media] winbond-cir: One variable and its check less in wbcir_shutdown() after error detection SF Markus Elfring
2016-10-15 13:29 ` Sean Young
2016-10-15 16:42 ` SF Markus Elfring
2016-10-19 13:10 ` David Härdeman
2016-10-19 13:50 ` SF Markus Elfring
2016-10-19 13:10 ` David Härdeman
2016-10-14 11:45 ` [PATCH 5/5] [media] winbond-cir: Move a variable assignment in two functions SF Markus Elfring
2016-10-19 13:03 ` [PATCH 1/5] [media] winbond-cir: Use kmalloc_array() in wbcir_tx() David Härdeman
2016-10-19 13:04 ` [PATCH 2/5] [media] winbond-cir: Move a variable assignment " David Härdeman
2016-10-19 13:32 ` SF Markus Elfring
2016-10-19 13:47 ` David Härdeman
2016-10-19 14:05 ` SF Markus Elfring
2016-10-19 13:07 ` [PATCH 3/5] [media] winbond-cir: Move assignments for three variables in wbcir_shutdown() David Härdeman
2016-10-19 13:38 ` SF Markus Elfring
2016-10-19 13:47 ` David Härdeman
2016-10-19 14:14 ` SF Markus Elfring
2016-10-19 13:10 ` [PATCH 5/5] [media] winbond-cir: Move a variable assignment in two functions David Härdeman
2016-10-19 13:53 ` SF Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7878868c-bc54-5577-b808-ed096bbf3759@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=hverkuil@xs4all.nl \
--cc=julia.lawall@lip6.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sean@mess.org \
--cc=wsa-dev@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).