Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp318681pxb; Thu, 21 Jan 2021 07:52:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXB5Yfi8GQijhNPwcA3mWYmRWHhHmIUyDA+yE8Wc8Jzt7XngWmADU6J8EpMzTXeAEfhdDD X-Received: by 2002:a50:84e7:: with SMTP id 94mr12124333edq.87.1611244349990; Thu, 21 Jan 2021 07:52:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611244349; cv=none; d=google.com; s=arc-20160816; b=h1iqSvs5H9b8gGOirTrMszs5IXpaRixSW7910LLf4vDchyrmz9m8VYyvnMXULCt1GY VcIPt1dBysHJnEnTI7/8LrRj8ign58yXp3Nvf8gNORADwuU2X6nKOB8Bj96q2sacXpJA VYkN4/xQ1fUF0h8EREDXYjhHj3/6TAs2iONXy7j5dio9L1el69DukQvJrKymZ9RDxt+q p43zvKoUVKncVT5zxUU4NibENSToyaufhKoshwL0NYa0S3U5nekRg5g6lkMrhbRJBO/1 cJRF1MRjjEhp03y8lQCkHVjd1HduaXjZwjRbrN5Fm5SmGXpRCTWNF1dKVaa1RbON+S3E cbWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=K1giwXDXKQTjt+nBGQAGwKAeKm4ryuwZS7DP+3mpgv8=; b=KPs0ecmO44cjBK6eNwHv/IdxW6+T8ThzuAMq2UOC/zr05EMHbRuBWfi/eSnCs0+AmH 5f8thhi5ND+/fQ2l5ZFC8hrBIaq16QOX2DNiZx8row9THmBQce3iW3aSo5VjIBiFGGgX d6oUYOckFPfVg7W61XN2meZzYJzHK8hAETIKmk6WcoVBjpuPvn1BUDTSYb5mf6ObD2dT TFfmZJ71NrzkoX2WNdkRC7yn+q1DyW+7c8LIOQ9hDeu6qZmHvZi9YSXqwm+jxX2VNdXt 5JrzGBV5u/IK/0IO6AzFAheto6VnV4UgrgdhbtpOwYEBxvBAfWmA19tCeFHKz634Qceb T9Og== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gw11si1890630ejb.414.2021.01.21.07.52.04; Thu, 21 Jan 2021 07:52:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732963AbhAUPsB (ORCPT + 99 others); Thu, 21 Jan 2021 10:48:01 -0500 Received: from netrider.rowland.org ([192.131.102.5]:58435 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1731929AbhAUPqi (ORCPT ); Thu, 21 Jan 2021 10:46:38 -0500 Received: (qmail 255135 invoked by uid 1000); 21 Jan 2021 10:45:33 -0500 Date: Thu, 21 Jan 2021 10:45:33 -0500 From: Alan Stern To: Oh Eomji Cc: balbi@kernel.org, Greg Kroah-Hartman , "Gustavo A. R. Silva" , Andy Shevchenko , Bart Van Assche , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: gadget: f_mass_storage: cahnge wait_event to wait_event_timeout Message-ID: <20210121154533.GA254122@rowland.harvard.edu> References: <1611212208-84202-1-git-send-email-eomji.oh@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1611212208-84202-1-git-send-email-eomji.oh@samsung.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 21, 2021 at 03:56:45PM +0900, Oh Eomji wrote: > Changed to return a timeout error if there is no response for a certain > period of time in order to solve the problem of waiting for a event > complete while executing unbind. > > Signed-off-by: Oh Eomji > --- > drivers/usb/gadget/function/f_mass_storage.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c > index 950c943..b474840 100644 > --- a/drivers/usb/gadget/function/f_mass_storage.c > +++ b/drivers/usb/gadget/function/f_mass_storage.c > @@ -3000,7 +3000,7 @@ static void fsg_unbind(struct usb_configuration *c, struct usb_function *f) > if (fsg->common->fsg == fsg) { > __raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE, NULL); > /* FIXME: make interruptible or killable somehow? */ > - wait_event(common->fsg_wait, common->fsg != fsg); > + wait_event_timeout(common->fsg_wait, common->fsg != fsg, HZ / 4); > } > > usb_free_all_descriptors(&fsg->function); No, no, no! This patch completely misunderstands the purpose of the wait_event call. The reason it isn't interruptible is not because that would be difficult -- all it takes is adding a timeout argument, as you did here. The reason is because the driver will get invalid memory accesses if fsg_unbind returns too early. fsg will be deallocated, but fsg_set_interface will continue to use it. This patch completely ignores that issue. Was there any real reason for writing this patch? Does it solve a real-world problem? Did you encounter a situation where the wait_event call would wait for more than 1/4 second? Alan Stern