diff mbox

[v1] tcmu: free old string on reconfig

Message ID 1500037864-52123-1-git-send-email-bryantly@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bryant G. Ly July 14, 2017, 1:11 p.m. UTC
On initial tcmu_configure_device call the info->name would
have already been allocated and set, so on the second call
make sure to free it first.

Reported-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
---
 drivers/target/target_core_user.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Mike Christie July 14, 2017, 5:24 p.m. UTC | #1
On 07/14/2017 08:11 AM, Bryant G. Ly wrote:
> On initial tcmu_configure_device call the info->name would
> have already been allocated and set, so on the second call
> make sure to free it first.
> 
> Reported-by: Mike Christie <mchristi@redhat.com>
> Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
> ---
>  drivers/target/target_core_user.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index 80ee130..e366260 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -1433,6 +1433,8 @@ static int tcmu_update_uio_info(struct tcmu_dev *udev)
>  	if (udev->dev_config[0])
>  		snprintf(str + used, size - used, "/%s", udev->dev_config);
>  
> +	/* If the old string exists, free it */
> +	kfree(info->name);
>  	info->name = str;
>  
>  	return 0;
> 

Reviewed-by: Mike Christie <mchristi@redhat.com>
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Nicholas A. Bellinger July 30, 2017, 10:24 p.m. UTC | #2
On Fri, 2017-07-14 at 08:11 -0500, Bryant G. Ly wrote:
> On initial tcmu_configure_device call the info->name would
> have already been allocated and set, so on the second call
> make sure to free it first.
> 
> Reported-by: Mike Christie <mchristi@redhat.com>
> Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
> ---
>  drivers/target/target_core_user.c | 2 ++
>  1 file changed, 2 insertions(+)
> 

Applied to target-pending/master.

Thanks Bryant + MNC.

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 80ee130..e366260 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1433,6 +1433,8 @@  static int tcmu_update_uio_info(struct tcmu_dev *udev)
 	if (udev->dev_config[0])
 		snprintf(str + used, size - used, "/%s", udev->dev_config);
 
+	/* If the old string exists, free it */
+	kfree(info->name);
 	info->name = str;
 
 	return 0;