From: Arvind Yadav <arvind.yadav.cs@gmail.com>
To: p.zabel@pengutronix.de, mchehab@kernel.org,
hans.verkuil@cisco.com, sean@mess.org, andi.shyti@samsung.com
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] [media] cx23885: Handle return value of kasprintf
Date: Wed, 20 Sep 2017 13:07:13 +0530 [thread overview]
Message-ID: <1505893033-7491-3-git-send-email-arvind.yadav.cs@gmail.com> (raw)
In-Reply-To: <1505893033-7491-1-git-send-email-arvind.yadav.cs@gmail.com>
kasprintf() can fail here and we must check its return value.
Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
drivers/media/pci/cx23885/cx23885-input.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/media/pci/cx23885/cx23885-input.c b/drivers/media/pci/cx23885/cx23885-input.c
index 944b7083..0f4e542 100644
--- a/drivers/media/pci/cx23885/cx23885-input.c
+++ b/drivers/media/pci/cx23885/cx23885-input.c
@@ -340,14 +340,23 @@ int cx23885_input_init(struct cx23885_dev *dev)
kernel_ir->cx = dev;
kernel_ir->name = kasprintf(GFP_KERNEL, "cx23885 IR (%s)",
cx23885_boards[dev->board].name);
+ if (!kernel_ir->name) {
+ ret = -ENOMEM;
+ goto err_out_free;
+ }
+
kernel_ir->phys = kasprintf(GFP_KERNEL, "pci-%s/ir0",
pci_name(dev->pci));
+ if (!kernel_ir->phys) {
+ ret = -ENOMEM;
+ goto err_out_free_name;
+ }
/* input device */
rc = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rc) {
ret = -ENOMEM;
- goto err_out_free;
+ goto err_out_free_phys;
}
kernel_ir->rc = rc;
@@ -382,9 +391,11 @@ int cx23885_input_init(struct cx23885_dev *dev)
cx23885_input_ir_stop(dev);
dev->kernel_ir = NULL;
rc_free_device(rc);
-err_out_free:
+err_out_free_phys:
kfree(kernel_ir->phys);
+err_out_free_name:
kfree(kernel_ir->name);
+err_out_free:
kfree(kernel_ir);
return ret;
}
--
1.9.1
prev parent reply other threads:[~2017-09-20 7:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-20 7:37 [PATCH 0/2] [media] Handle return value of kasprintf Arvind Yadav
2017-09-20 7:37 ` [PATCH 1/2] [media] coda: " Arvind Yadav
2017-09-20 8:30 ` Philipp Zabel
2017-09-20 7:37 ` Arvind Yadav [this message]
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=1505893033-7491-3-git-send-email-arvind.yadav.cs@gmail.com \
--to=arvind.yadav.cs@gmail.com \
--cc=andi.shyti@samsung.com \
--cc=hans.verkuil@cisco.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=sean@mess.org \
/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).