mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ivan Gomez Castellanos <ivan.gomez@ti.com>
To: linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, gregkh@suse.de
Cc: Hiroshi.DOYU@nokia.com, ameya.palande@nokia.com,
	felipe.contreras@nokia.com, omar.ramirez@ti.com, ohad@wizery.com,
	rene.sapiens@ti.com, nm@ti.com, ernesto@ti.com, x0095078@ti.com,
	Ivan Gomez Castellanos <ivan.gomez@ti.com>
Subject: [PATCH 06/11] staging: tidspbridge: Remove cfg_get_exec_file()
Date: Wed, 25 Aug 2010 17:08:59 -0500	[thread overview]
Message-ID: <1282774144-11628-7-git-send-email-ivan.gomez@ti.com> (raw)
In-Reply-To: <1282774144-11628-1-git-send-email-ivan.gomez@ti.com>

As the services directory is going to be removed, the cfg_get_exec_file
function has also to be removed.

This patch also avoids a possible NULL pointer dereference in function
cfg_get_exec_file(), when drv_datap is checked for NULL and then pass
drv_datap->base_img as argument to strlen().

Signed-off-by: Ivan Gomez Castellanos <ivan.gomez@ti.com>
---
 .../staging/tidspbridge/include/dspbridge/cfg.h    |   22 --------------
 drivers/staging/tidspbridge/rmgr/proc.c            |   27 ++++++++++++-----
 drivers/staging/tidspbridge/services/cfg.c         |   31 --------------------
 3 files changed, 19 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/tidspbridge/include/dspbridge/cfg.h b/drivers/staging/tidspbridge/include/dspbridge/cfg.h
index 9a259a1..11f5bde 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/cfg.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/cfg.h
@@ -41,28 +41,6 @@
 extern int cfg_get_cd_version(u32 *version);
 
 /*
- *  ======== cfg_get_exec_file ========
- *  Purpose:
- *      Retreive the default executable, if any, for this board.
- *  Parameters:
- *      dev_node_obj: Handle to the dev_node who's driver we are querying.
- *      buf_size:       Size of buffer.
- *      str_exec_file:  Ptr to character buf to hold ExecFile.
- *  Returns:
- *      0:                Success.
- *      -EFAULT:  dev_node_obj is invalid or str_exec_file is invalid.
- *      -ENODATA: The resource is not available.
- *  Requires:
- *      CFG initialized.
- *  Ensures:
- *      0:    Not more than buf_size bytes were copied into str_exec_file,
- *                  and *str_exec_file contains default executable for this
- *                  devnode.
- */
-extern int cfg_get_exec_file(struct cfg_devnode *dev_node_obj,
-				    u32 buf_size, char *str_exec_file);
-
-/*
  *  ======== cfg_get_object ========
  *  Purpose:
  *      Retrieve the Driver Object handle From the Registry
diff --git a/drivers/staging/tidspbridge/rmgr/proc.c b/drivers/staging/tidspbridge/rmgr/proc.c
index 44c26e1..0a7e30b 100644
--- a/drivers/staging/tidspbridge/rmgr/proc.c
+++ b/drivers/staging/tidspbridge/rmgr/proc.c
@@ -393,18 +393,29 @@ static int get_exec_file(struct cfg_devnode *dev_node_obj,
 {
 	u8 dev_type;
 	s32 len;
+	struct drv_data *drv_datap = dev_get_drvdata(bridge);
 
 	dev_get_dev_type(hdev_obj, (u8 *) &dev_type);
+
+	if (!exec_file)
+		return -EFAULT;
+
 	if (dev_type == DSP_UNIT) {
-		return cfg_get_exec_file(dev_node_obj, size, exec_file);
-	} else if (dev_type == IVA_UNIT) {
-		if (iva_img) {
-			len = strlen(iva_img);
-			strncpy(exec_file, iva_img, len + 1);
-			return 0;
-		}
+		if (!drv_datap || !drv_datap->base_img)
+			return -EFAULT;
+
+		if (strlen(drv_datap->base_img) > size)
+			return -EINVAL;
+
+		strcpy(exec_file, drv_datap->base_img);
+	} else if (dev_type == IVA_UNIT && iva_img) {
+		len = strlen(iva_img);
+		strncpy(exec_file, iva_img, len + 1);
+	} else {
+		return -ENOENT;
 	}
-	return -ENOENT;
+
+	return 0;
 }
 
 /*
diff --git a/drivers/staging/tidspbridge/services/cfg.c b/drivers/staging/tidspbridge/services/cfg.c
index 587c71a..302eadd 100644
--- a/drivers/staging/tidspbridge/services/cfg.c
+++ b/drivers/staging/tidspbridge/services/cfg.c
@@ -31,37 +31,6 @@
 #include <dspbridge/drv.h>
 
 /*
- *  ======== cfg_get_exec_file ========
- *  Purpose:
- *      Retreive the default executable, if any, for this board.
- */
-int cfg_get_exec_file(struct cfg_devnode *dev_node_obj, u32 buf_size,
-			     char *str_exec_file)
-{
-	int status = 0;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	if (!dev_node_obj)
-		status = -EFAULT;
-
-	else if (!str_exec_file || !drv_datap)
-		status = -EFAULT;
-
-	if (strlen(drv_datap->base_img) > buf_size)
-		status = -EINVAL;
-
-	if (!status && drv_datap->base_img)
-		strcpy(str_exec_file, drv_datap->base_img);
-
-	if (status)
-		pr_err("%s: Failed, status 0x%x\n", __func__, status);
-	DBC_ENSURE(((status == 0) &&
-		    (strlen(str_exec_file) <= buf_size))
-		   || (status != 0));
-	return status;
-}
-
-/*
  *  ======== cfg_get_object ========
  *  Purpose:
  *      Retrieve the Object handle from the Registry
-- 
1.7.0.3


  parent reply	other threads:[~2010-08-25 22:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-25 22:08 [PATCH 00/11] staging: tidspbridge: Remove services directory Ivan Gomez Castellanos
2010-08-25 22:08 ` [PATCH 01/11] staging: tidspbridge: Move sync.c from services to core Ivan Gomez Castellanos
2010-08-25 22:08 ` [PATCH 02/11] staging: tidspbridge: Remove ntfy.c Ivan Gomez Castellanos
2010-08-25 22:08 ` [PATCH 03/11] staging: tidspbridge: Remove cfg_get_auto_start() Ivan Gomez Castellanos
2010-08-25 22:08 ` [PATCH 04/11] staging: tidspbridge: Remove cfg_init() and cfg_exit() Ivan Gomez Castellanos
2010-08-25 22:08 ` [PATCH 05/11] staging: tidspbridge: Remove cfg_get_dev_object() and do a trivial cleanup Ivan Gomez Castellanos
2010-08-25 22:08 ` Ivan Gomez Castellanos [this message]
2010-08-25 22:09 ` [PATCH 07/11] staging: tidspbridge: Remove cfg_get_object() Ivan Gomez Castellanos
2010-08-25 22:09 ` [PATCH 08/11] staging: tidspbridge: Remove cfg_set_dev_object() Ivan Gomez Castellanos
2010-08-25 22:09 ` [PATCH 09/11] staging: tidspbridge: Remove cfg_set_object() Ivan Gomez Castellanos
2010-08-25 22:09 ` [PATCH 10/11] staging: tidspbridge: Remove cfg.c and cfg.h files Ivan Gomez Castellanos
2010-08-25 22:09 ` [PATCH 11/11] staging: tidspbridge: Remove services.c and services.h Ivan Gomez Castellanos

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=1282774144-11628-7-git-send-email-ivan.gomez@ti.com \
    --to=ivan.gomez@ti.com \
    --cc=Hiroshi.DOYU@nokia.com \
    --cc=ameya.palande@nokia.com \
    --cc=ernesto@ti.com \
    --cc=felipe.contreras@nokia.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=ohad@wizery.com \
    --cc=omar.ramirez@ti.com \
    --cc=rene.sapiens@ti.com \
    --cc=x0095078@ti.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

all inboxes | Powered by JetHome®