From patchwork Fri Jul 7 16:05:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Aoqui X-Patchwork-Id: 786179 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3x5kpS6ggQz9sNv; Mon, 10 Jul 2017 22:21:20 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1dUXgk-0006pl-4D; Mon, 10 Jul 2017 12:21:18 +0000 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5] helo=mx0a-001b2d01.pphosted.com) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1dTVnJ-0006F3-C3 for kernel-team@lists.ubuntu.com; Fri, 07 Jul 2017 16:07:49 +0000 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v67G48uC014982 for ; Fri, 7 Jul 2017 12:07:48 -0400 Received: from e24smtp02.br.ibm.com (e24smtp02.br.ibm.com [32.104.18.86]) by mx0b-001b2d01.pphosted.com with ESMTP id 2bjcmja9kh-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 07 Jul 2017 12:07:48 -0400 Received: from localhost by e24smtp02.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 7 Jul 2017 13:07:46 -0300 Received: from d24relay03.br.ibm.com (9.13.39.225) by e24smtp02.br.ibm.com (10.172.0.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 7 Jul 2017 13:07:44 -0300 Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay03.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v67G3Ohr22544566 for ; Fri, 7 Jul 2017 13:03:24 -0300 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v67G7iLm017845 for ; Fri, 7 Jul 2017 13:07:44 -0300 Received: from localhost ([9.85.153.43]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v67G7gCl017818; Fri, 7 Jul 2017 13:07:43 -0300 From: Victor Aoqui To: kernel-team@lists.ubuntu.com Subject: [Zesty][PATCH 42/44] scsi: cxlflash: Avoid double free of character device Date: Fri, 7 Jul 2017 13:05:56 -0300 X-Mailer: git-send-email 2.11.0 (Apple Git-81) In-Reply-To: <20170707160558.2383-1-victora@br.ibm.com> References: <20170707160558.2383-1-victora@br.ibm.com> X-TM-AS-MML: disable x-cbid: 17070716-0020-0000-0000-000002BDF60E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070716-0021-0000-0000-000030DD06C9 Message-Id: <20170707160558.2383-43-victora@br.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-07_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1707070268 X-Mailman-Approved-At: Mon, 10 Jul 2017 12:20:37 +0000 Cc: victora@br.ibm.com, mauricfo@linux.vnet.ibm.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: "Matthew R. Ochs" BugLink: http://bugs.launchpad.net/bugs/1702521 The device_unregister() service used when cleaning up the character device is already responsible for the internal state associated with the device upon successful creation. As the cxlflash driver does not obtain a second reference to the character device, the explicit call to put_device() is not required and can lead to an inconsistent sysfs among other issues as the reference is no longer valid after the first put_device() is performed. Remove the unnecessary put_device() to remedy this issue. Fixes: a834a36b57d9 ("scsi: cxlflash: Create character device to provide host management interface") Signed-off-by: Matthew R. Ochs Reviewed-by: Hannes Reinecke Signed-off-by: Martin K. Petersen (cherry picked from commit acfeb23b29894deaee65d63c55bea09183f6b538) Signed-off-by: Victor Aoqui --- drivers/scsi/cxlflash/main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 7a787b6e21c4..455564fb6c4d 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -923,7 +923,6 @@ static void cxlflash_put_minor(int minor) */ static void cxlflash_release_chrdev(struct cxlflash_cfg *cfg) { - put_device(cfg->chardev); device_unregister(cfg->chardev); cfg->chardev = NULL; cdev_del(&cfg->cdev);