{"id":806042,"url":"http://patchwork.ozlabs.org/api/1.2/patches/806042/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1503699483-61541-1-git-send-email-ukrishn@linux.vnet.ibm.com/","project":{"id":2,"url":"http://patchwork.ozlabs.org/api/1.2/projects/2/?format=json","name":"Linux PPC development","link_name":"linuxppc-dev","list_id":"linuxppc-dev.lists.ozlabs.org","list_email":"linuxppc-dev@lists.ozlabs.org","web_url":"https://github.com/linuxppc/wiki/wiki","scm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git","webscm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/","list_archive_url":"https://lore.kernel.org/linuxppc-dev/","list_archive_url_format":"https://lore.kernel.org/linuxppc-dev/{}/","commit_url_format":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"},"msgid":"<1503699483-61541-1-git-send-email-ukrishn@linux.vnet.ibm.com>","list_archive_url":"https://lore.kernel.org/linuxppc-dev/1503699483-61541-1-git-send-email-ukrishn@linux.vnet.ibm.com/","date":"2017-08-25T22:18:03","name":"[2/3] cxlflash: Avoid double mutex unlock","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"6ca6be00d0b86c68380d78a140424f67651d756f","submitter":{"id":67825,"url":"http://patchwork.ozlabs.org/api/1.2/people/67825/?format=json","name":"Uma Krishnan","email":"ukrishn@linux.vnet.ibm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1503699483-61541-1-git-send-email-ukrishn@linux.vnet.ibm.com/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/806042/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/806042/checks/","tags":{},"related":[],"headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xfFzv6Mrrz9t3k\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 26 Aug 2017 08:23:23 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xfFzv4GFCzDrTh\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 26 Aug 2017 08:23:23 +1000 (AEST)","from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com\n\t[148.163.158.5])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xfFsx1MdYzDrSf\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tSat, 26 Aug 2017 08:18:12 +1000 (AEST)","from pps.filterd (m0098419.ppops.net [127.0.0.1])\n\tby mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv7PMDjrd004859\n\tfor <linuxppc-dev@lists.ozlabs.org>; Fri, 25 Aug 2017 18:18:10 -0400","from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204])\n\tby mx0b-001b2d01.pphosted.com with ESMTP id 2cjqmxxpgv-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <linuxppc-dev@lists.ozlabs.org>; Fri, 25 Aug 2017 18:18:10 -0400","from localhost\n\tby e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <linuxppc-dev@lists.ozlabs.org> from <ukrishn@linux.vnet.ibm.com>;\n\tFri, 25 Aug 2017 18:18:10 -0400","from b01cxnp22036.gho.pok.ibm.com (9.57.198.26)\n\tby e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway:\n\tAuthorized Use Only! Violators will be prosecuted; \n\tFri, 25 Aug 2017 18:18:07 -0400","from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com\n\t[9.57.199.110])\n\tby b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP\n\tid v7PMI7Jt31654102; Fri, 25 Aug 2017 22:18:07 GMT","from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id D96E5AE051;\n\tFri, 25 Aug 2017 18:18:29 -0400 (EDT)","from p8tul1-build.aus.stglabs.ibm.com (unknown [9.3.141.206])\n\tby b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id 2F0E6AE034;\n\tFri, 25 Aug 2017 18:18:29 -0400 (EDT)"],"From":"Uma Krishnan <ukrishn@linux.vnet.ibm.com>","To":"linux-scsi@vger.kernel.org, James Bottomley <jejb@linux.vnet.ibm.com>,\n\t\"Martin K. Petersen\" <martin.petersen@oracle.com>,\n\t\"Matthew R. Ochs\" <mrochs@linux.vnet.ibm.com>,\n\t\"Manoj N. Kumar\" <manoj@linux.vnet.ibm.com>","Subject":"[PATCH 2/3] cxlflash: Avoid double mutex unlock","Date":"Fri, 25 Aug 2017 17:18:03 -0500","X-Mailer":"git-send-email 2.1.0","In-Reply-To":"<1503699440-61464-1-git-send-email-ukrishn@linux.vnet.ibm.com>","References":"<1503699440-61464-1-git-send-email-ukrishn@linux.vnet.ibm.com>","X-TM-AS-GCONF":"00","x-cbid":"17082522-0052-0000-0000-00000255C847","X-IBM-SpamModules-Scores":"","X-IBM-SpamModules-Versions":"BY=3.00007611; HX=3.00000241; KW=3.00000007;\n\tPH=3.00000004; SC=3.00000225; SDB=6.00907628; UDB=6.00455029;\n\tIPR=6.00687827; \n\tBA=6.00005553; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009;\n\tZB=6.00000000; \n\tZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016867;\n\tXFM=3.00000015; UTC=2017-08-25 22:18:08","X-IBM-AV-DETECTION":"SAVI=unused REMOTE=unused XFE=unused","x-cbparentid":"17082522-0053-0000-0000-000051CA3C7C","Message-Id":"<1503699483-61541-1-git-send-email-ukrishn@linux.vnet.ibm.com>","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-08-25_06:, , signatures=0","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=0\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1708250339","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"linuxppc-dev@lists.ozlabs.org,\n\tFrederic Barrat <fbarrat@linux.vnet.ibm.com>, \n\tAndrew Donnellan <andrew.donnellan@au1.ibm.com>,\n\tChristophe Lombard <clombard@linux.vnet.ibm.com>","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"},"content":"From: \"Matthew R. Ochs\" <mrochs@linux.vnet.ibm.com>\n\nThe AFU recovery routine uses an interruptible mutex to control the\nflow of in-flight recoveries. Upon receiving an interruptible signal\nthe code branches to a common exit path which wrongly assumes the\nmutex is held. Add a local variable to track when the mutex should be\nunlocked.\n\nSigned-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>\nSigned-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>\n---\n drivers/scsi/cxlflash/superpipe.c | 13 ++++++++++---\n 1 file changed, 10 insertions(+), 3 deletions(-)","diff":"diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c\nindex ad0f996..e9ee1d9 100644\n--- a/drivers/scsi/cxlflash/superpipe.c\n+++ b/drivers/scsi/cxlflash/superpipe.c\n@@ -1650,6 +1650,7 @@ static int cxlflash_afu_recover(struct scsi_device *sdev,\n \tu64 ctxid = DECODE_CTXID(recover->context_id),\n \t    rctxid = recover->context_id;\n \tlong reg;\n+\tbool locked = true;\n \tint lretry = 20; /* up to 2 seconds */\n \tint new_adap_fd = -1;\n \tint rc = 0;\n@@ -1658,8 +1659,11 @@ static int cxlflash_afu_recover(struct scsi_device *sdev,\n \tup_read(&cfg->ioctl_rwsem);\n \trc = mutex_lock_interruptible(mutex);\n \tdown_read(&cfg->ioctl_rwsem);\n-\tif (rc)\n+\tif (rc) {\n+\t\tlocked = false;\n \t\tgoto out;\n+\t}\n+\n \trc = check_state(cfg);\n \tif (rc) {\n \t\tdev_err(dev, \"%s: Failed state rc=%d\\n\", __func__, rc);\n@@ -1693,8 +1697,10 @@ static int cxlflash_afu_recover(struct scsi_device *sdev,\n \t\t\t\tmutex_unlock(mutex);\n \t\t\t\tmsleep(100);\n \t\t\t\trc = mutex_lock_interruptible(mutex);\n-\t\t\t\tif (rc)\n+\t\t\t\tif (rc) {\n+\t\t\t\t\tlocked = false;\n \t\t\t\t\tgoto out;\n+\t\t\t\t}\n \t\t\t\tgoto retry_recover;\n \t\t\t}\n \n@@ -1738,7 +1744,8 @@ static int cxlflash_afu_recover(struct scsi_device *sdev,\n out:\n \tif (likely(ctxi))\n \t\tput_context(ctxi);\n-\tmutex_unlock(mutex);\n+\tif (locked)\n+\t\tmutex_unlock(mutex);\n \tatomic_dec_if_positive(&cfg->recovery_threads);\n \treturn rc;\n }\n","prefixes":["2/3"]}