mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] target/iblock: Fix memory leak in iblock_set_configfs_dev_params
@ 2011-01-16 23:04 Nicholas A. Bellinger
  2011-01-16 23:04 ` [PATCH] target: Fix memory leaks in target_core_dev_pr_store_attr_res_aptpl_metadata Nicholas A. Bellinger
  0 siblings, 1 reply; 2+ messages in thread
From: Nicholas A. Bellinger @ 2011-01-16 23:04 UTC (permalink / raw)
  To: linux-scsi, linux-kernel; +Cc: James Bottomley, Jesper Juhl, Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

The match_strdup() allocation for Opt_udev_path needs to be released
after usage.

Reported-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
 drivers/target/target_core_iblock.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 67f0c09..422187b 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -469,7 +469,7 @@ static ssize_t iblock_set_configfs_dev_params(struct se_hba *hba,
 					       const char *page, ssize_t count)
 {
 	struct iblock_dev *ib_dev = se_dev->se_dev_su_ptr;
-	char *orig, *ptr, *opts;
+	char *orig, *ptr, *arg_p, *opts;
 	substring_t args[MAX_OPT_ARGS];
 	int ret = 0, arg, token;
 
@@ -492,9 +492,14 @@ static ssize_t iblock_set_configfs_dev_params(struct se_hba *hba,
 				ret = -EEXIST;
 				goto out;
 			}
-
-			ret = snprintf(ib_dev->ibd_udev_path, SE_UDEV_PATH_LEN,
-				"%s", match_strdup(&args[0]));
+			arg_p = match_strdup(&args[0]);
+			if (!arg_p) {
+				ret = -ENOMEM;
+				break;
+			}
+			snprintf(ib_dev->ibd_udev_path, SE_UDEV_PATH_LEN,
+					"%s", arg_p);
+			kfree(arg_p);
 			printk(KERN_INFO "IBLOCK: Referencing UDEV path: %s\n",
 					ib_dev->ibd_udev_path);
 			ib_dev->ibd_flags |= IBDF_HAS_UDEV_PATH;
-- 
1.5.6.5


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-16 23:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-16 23:04 [PATCH] target/iblock: Fix memory leak in iblock_set_configfs_dev_params Nicholas A. Bellinger
2011-01-16 23:04 ` [PATCH] target: Fix memory leaks in target_core_dev_pr_store_attr_res_aptpl_metadata Nicholas A. Bellinger

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®