From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECA78C433E0 for ; Thu, 14 Jan 2021 06:41:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AED69238EA for ; Thu, 14 Jan 2021 06:41:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726075AbhANGlp (ORCPT ); Thu, 14 Jan 2021 01:41:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725975AbhANGlp (ORCPT ); Thu, 14 Jan 2021 01:41:45 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26F4EC061575; Wed, 13 Jan 2021 22:41:04 -0800 (PST) Date: Thu, 14 Jan 2021 07:41:00 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1610606462; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VB3LT83nvUNrPtVk0ucHr6Pvx44lX5Zq06M2c7g1170=; b=1a9gqTj8yNOQRj+3I8iqQHVwK5ueMkNbCXzamDAgWwASRq+MzcGW0m9sNjXuLJsTwpX8kp Wpxxb4uZwTSHwdBTPHUZaFkoDfm3dHlEXPL0r/EL7rDfr7PIWjorQUclyz88gzhWWmG+82 SQ3fwdKxM87m/mfg9booNeXrOgaOTy3qhUfo5r8iKsA6mK9rtUZe5Lixi/tkxRVdVZnods Kj879j1RkQ7dsJZ39cuIcBoX9RGj9VgjufQU5dtI9OESP5X9cjO9VtW5PlKCItsVu6/jjF VvQQHXmx2EMbLTmlfhLb91GfFs+tZeeU1y1g4OdDgd9b6mRiRmbcM7zdBWmvjw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1610606462; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VB3LT83nvUNrPtVk0ucHr6Pvx44lX5Zq06M2c7g1170=; b=u0PWeUA9ko6hRjuvT4NezRR2RadT00GM1osGA77IrHXHJBlu++h1pi3E2scmQNaYcWGdHg OKeoMuhpZqf+s+Dw== From: "Ahmed S. Darwish" To: Thinh Nguyen Cc: Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org, Peter Chen , Lee Jones , Alan Stern , Dejin Zheng , Sebastian Andrzej Siewior , Michal Nazarewicz , stable@vger.kernel.org Subject: Re: [PATCH v2] usb: udc: core: Use lock when write to soft_connect Message-ID: References: <311bc6d30b23427420133602c2833308310b7fcb.1610595364.git.Thinh.Nguyen@synopsys.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <311bc6d30b23427420133602c2833308310b7fcb.1610595364.git.Thinh.Nguyen@synopsys.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Wed, Jan 13, 2021 at 07:38:28PM -0800, Thinh Nguyen wrote: ... > @@ -1543,10 +1546,12 @@ static ssize_t soft_connect_store(struct device *dev, > usb_gadget_udc_stop(udc); > } else { > dev_err(dev, "unsupported command '%s'\n", buf); > - return -EINVAL; > + ret = -EINVAL; > } > > - return n; > +out: > + mutex_unlock(&udc_lock); > + return ret; > } This is *very* tricky: the return value will be easily broken if someone adds any code later after the else body and before the "out" label.