From patchwork Thu Jun 22 06:21:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tang.wenji@zte.com.cn X-Patchwork-Id: 9803571 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 C6C2460386 for ; Thu, 22 Jun 2017 06:29:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5630285A7 for ; Thu, 22 Jun 2017 06:29:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7934285E5; Thu, 22 Jun 2017 06:29:48 +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 E5714285A7 for ; Thu, 22 Jun 2017 06:29:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752062AbdFVG3r (ORCPT ); Thu, 22 Jun 2017 02:29:47 -0400 Received: from mxhk.zte.com.cn ([63.217.80.70]:34153 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751064AbdFVG3r (ORCPT ); Thu, 22 Jun 2017 02:29:47 -0400 X-Greylist: delayed 406 seconds by postgrey-1.27 at vger.kernel.org; Thu, 22 Jun 2017 02:29:46 EDT X-scanvirus: By SEG_CYREN AntiVirus Engine X-scanresult: CLEAN X-MAILFROM: X-RCPTTO: X-FROMIP: 10.30.3.20 X-SEG-Scaned: 1 X-Received: unknown,10.30.3.20,20170622141538 Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 22 Jun 2017 06:15:38 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v5M6MF3K074555; Thu, 22 Jun 2017 14:22:15 +0800 (GMT-8) (envelope-from tang.wenji@zte.com.cn) Received: from localhost.localdomain ([10.118.202.203]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2017062214221963-2039131 ; Thu, 22 Jun 2017 14:22:19 +0800 From: tang.wenji@zte.com.cn To: Nicholas Bellinger Cc: tang.wenji@zte.com.cn, target-devel@vger.kernel.org Subject: [PATCH] tcmu:add reference count of dev in tcmu_open function Date: Thu, 22 Jun 2017 14:21:06 +0800 Message-Id: <1498112466-8900-1-git-send-email-tang.wenji@zte.com.cn> X-Mailer: git-send-email 2.8.1.windows.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-06-22 14:22:20, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-06-22 14:22:03, Serialize complete at 2017-06-22 14:22:03 X-MAIL: mse01.zte.com.cn v5M6MF3K074555 X-HQIP: 127.0.0.1 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 From: Wenji Tang In the tcmu_open function does not increase the reference count of dev, but in the tcmu_release function to decrease its reference count. When the user oepn/close device many times, the corresponding dev device is illegally released Signed-off-by: Wenji Tang --- 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 beb5f09..376a290 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -1142,6 +1142,8 @@ static int tcmu_open(struct uio_info *info, struct inode *inode) udev->inode = inode; pr_debug("open\n"); + + kref_get(&udev->kref); return 0; }