linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ji-Hun Kim <ji_hun.kim@samsung.com>
To: mchehab@kernel.org
Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	ji_hun.kim@samsung.com, arvind.yadav.cs@gmail.com,
	linux-media@vger.kernel.org
Subject: [PATCH] staging: media: davinci_vpfe: add error handling on kmalloc failure
Date: Fri, 16 Mar 2018 13:58:23 +0900	[thread overview]
Message-ID: <1521176303-17546-1-git-send-email-ji_hun.kim@samsung.com> (raw)
In-Reply-To: CGME20180316045841epcas2p34dc11231c65e2032e88ac7138db2daee@epcas2p3.samsung.com

There is no failure checking on the param value which will be allocated
memory by kmalloc. Add a null pointer checking statement. Then goto error:
and return -ENOMEM error code when kmalloc is failed.

Signed-off-by: Ji-Hun Kim <ji_hun.kim@samsung.com>
---
 drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
index 6a3434c..55a922c 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
@@ -1280,6 +1280,10 @@ static int ipipe_s_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg)
 
 			params = kmalloc(sizeof(struct ipipe_module_params),
 					 GFP_KERNEL);
+			if (!params) {
+				rval = -ENOMEM;
+				goto error;
+			}
 			to = (void *)params + module_if->param_offset;
 			size = module_if->param_size;
 
@@ -1323,6 +1327,10 @@ static int ipipe_g_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg)
 
 			params =  kmalloc(sizeof(struct ipipe_module_params),
 						GFP_KERNEL);
+			if (!params) {
+				rval = -ENOMEM;
+				goto error;
+			}
 			from = (void *)params + module_if->param_offset;
 			size = module_if->param_size;
 
-- 
1.9.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

       reply	other threads:[~2018-03-16  4:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180316045841epcas2p34dc11231c65e2032e88ac7138db2daee@epcas2p3.samsung.com>
2018-03-16  4:58 ` Ji-Hun Kim [this message]
2018-03-16  8:32   ` [PATCH] staging: media: davinci_vpfe: add error handling on kmalloc failure Dan Carpenter
2018-03-19  4:24     ` Ji-Hun Kim
2018-03-19  7:14       ` Dan Carpenter

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=1521176303-17546-1-git-send-email-ji_hun.kim@samsung.com \
    --to=ji_hun.kim@samsung.com \
    --cc=arvind.yadav.cs@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.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).