From patchwork Fri Jul 14 13:11:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bryant G. Ly" X-Patchwork-Id: 9841017 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 64A85602D8 for ; Fri, 14 Jul 2017 13:11:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56A0E28779 for ; Fri, 14 Jul 2017 13:11:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B64228788; Fri, 14 Jul 2017 13:11:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECAE228779 for ; Fri, 14 Jul 2017 13:11:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753683AbdGNNLM (ORCPT ); Fri, 14 Jul 2017 09:11:12 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59206 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753606AbdGNNLL (ORCPT ); Fri, 14 Jul 2017 09:11:11 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6ED9dcp102762 for ; Fri, 14 Jul 2017 09:11:11 -0400 Received: from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bpmfwe69y-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 14 Jul 2017 09:11:10 -0400 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 14 Jul 2017 09:11:09 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 14 Jul 2017 09:11:07 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6EDB4Jc24445120; Fri, 14 Jul 2017 13:11:06 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 294DF124050; Fri, 14 Jul 2017 09:08:34 -0400 (EDT) Received: from localhost.localdomain (unknown [9.80.217.23]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id C0E26124035; Fri, 14 Jul 2017 09:08:33 -0400 (EDT) From: "Bryant G. Ly" To: nab@linux-iscsi.org, mchristi@redhat.com Cc: target-devel@vger.kernel.org, "Bryant G. Ly" Subject: [PATCH v1] tcmu: free old string on reconfig Date: Fri, 14 Jul 2017 08:11:04 -0500 X-Mailer: git-send-email 2.5.4 (Apple Git-61) X-TM-AS-GCONF: 00 x-cbid: 17071413-0044-0000-0000-0000036DE056 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007364; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00887440; UDB=6.00443090; IPR=6.00667591; BA=6.00005470; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016225; XFM=3.00000015; UTC=2017-07-14 13:11:08 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071413-0045-0000-0000-0000079BE518 Message-Id: <1500037864-52123-1-git-send-email-bryantly@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-13_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707140215 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Bryant G. Ly Reviewed-by: Mike Christie --- 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;