From patchwork Mon Jul 13 13:44:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 51070 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 23F4020319 for ; Mon, 13 Jul 2015 13:46:09 +0000 (UTC) Received: by widjy10 with SMTP id jy10sf21070722wid.3 for ; Mon, 13 Jul 2015 06:46:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=I5qMJWlBmaUwwew2qwjFndKdA3R0xFSMsK0uE7zPQqk=; b=hokOBoraFT/yTa4EUqyHwhkEmgRZgBhbvQ79cAW1RHRncBfNzhmS9gXXt26k4BYaws XkjrE1QmV24X2C9Vep0wOWJybDEkNinrVU5tejxVZB4a1amXvkIoxJXgaGiK+2jrSpFI OCocjOmU1IpNqAon9uesJlH7v51lyy26+6TYe9MD3JOqokm0ez0lVGY15/OB8SP/4r9T n1nMSID5Pm7AcyC4TTFTti93Ir+QSJYM47EY2OBeQcFSnS08lB9SmUfW/jon2Bw/eTKP 4g4TeHnuJW/Y0iN/nprx6Y0tNGuLISwBsgK2Zr1yb1dATi4yGA80ZId07asOnPeHYBoJ m9iQ== X-Gm-Message-State: ALoCoQlBSJllpkFzWtzcgO+Zr4+2wYk0J6mIOuRkQ4ryODhrINSEUvS7dK6Q/+gzc1xIK78B4A5x X-Received: by 10.152.27.130 with SMTP id t2mr18590092lag.2.1436795168455; Mon, 13 Jul 2015 06:46:08 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.70 with SMTP id z6ls1538766lag.9.gmail; Mon, 13 Jul 2015 06:46:08 -0700 (PDT) X-Received: by 10.112.145.132 with SMTP id su4mr31567993lbb.85.1436795168318; Mon, 13 Jul 2015 06:46:08 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id jv10si15353076lbc.13.2015.07.13.06.46.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Jul 2015 06:46:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lblf12 with SMTP id f12so55524681lbl.2 for ; Mon, 13 Jul 2015 06:46:08 -0700 (PDT) X-Received: by 10.112.55.207 with SMTP id u15mr32406834lbp.88.1436795168218; Mon, 13 Jul 2015 06:46:08 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1742094lbb; Mon, 13 Jul 2015 06:46:07 -0700 (PDT) X-Received: by 10.70.94.42 with SMTP id cz10mr42234782pdb.92.1436795154378; Mon, 13 Jul 2015 06:45:54 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dl10si28595622pdb.10.2015.07.13.06.45.53; Mon, 13 Jul 2015 06:45:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751669AbbGMNpw (ORCPT + 2 others); Mon, 13 Jul 2015 09:45:52 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:46394 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751636AbbGMNpu (ORCPT ); Mon, 13 Jul 2015 09:45:50 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t6DDjm9d010133 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 Jul 2015 13:45:48 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t6DDjmWJ031329 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 13 Jul 2015 13:45:48 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t6DDj6w0003520; Mon, 13 Jul 2015 13:45:14 GMT Received: from lappy.hsd1.nh.comcast.net (/10.154.113.225) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 13 Jul 2015 06:45:05 -0700 From: Sasha Levin To: stable@vger.kernel.org, stable-commits@vger.kernel.org Cc: Rui Miguel Silva , Felipe Balbi , Sasha Levin Subject: [added to the 3.18 stable tree] usb: gadget: f_fs: add extra check before unregister_gadget_item Date: Mon, 13 Jul 2015 09:44:17 -0400 Message-Id: <1436795065-27444-29-git-send-email-sasha.levin@oracle.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436795065-27444-1-git-send-email-sasha.levin@oracle.com> References: <1436795065-27444-1-git-send-email-sasha.levin@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Rui Miguel Silva This patch has been added to the 3.18 stable tree. If you have any objections, please let us know. =============== [ Upstream commit f14e9ad17f46051b02bffffac2036486097de19e ] ffs_closed can race with configfs_rmdir which will call config_item_release, so add an extra check to avoid calling the unregister_gadget_item with an null gadget item. Signed-off-by: Rui Miguel Silva Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/gadget/function/f_fs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 63314ed..ab9b7ac 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -3400,6 +3400,7 @@ done: static void ffs_closed(struct ffs_data *ffs) { struct ffs_dev *ffs_obj; + struct f_fs_opts *opts; ENTER(); ffs_dev_lock(); @@ -3413,8 +3414,13 @@ static void ffs_closed(struct ffs_data *ffs) if (ffs_obj->ffs_closed_callback) ffs_obj->ffs_closed_callback(ffs); - if (!ffs_obj->opts || ffs_obj->opts->no_configfs - || !ffs_obj->opts->func_inst.group.cg_item.ci_parent) + if (ffs_obj->opts) + opts = ffs_obj->opts; + else + goto done; + + if (opts->no_configfs || !opts->func_inst.group.cg_item.ci_parent + || !atomic_read(&opts->func_inst.group.cg_item.ci_kref.refcount)) goto done; unregister_gadget_item(ffs_obj->opts->