Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4004571ybc; Thu, 14 Nov 2019 19:21:34 -0800 (PST) X-Google-Smtp-Source: APXvYqwaxDRw07TJiwvoGTdgsYNcMyamt/6brnueziPKLmBZxhhGMrnSc3pDRzyLsA+ADxh4eN/v X-Received: by 2002:a17:906:2e5a:: with SMTP id r26mr10514828eji.283.1573788094193; Thu, 14 Nov 2019 19:21:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573788094; cv=none; d=google.com; s=arc-20160816; b=R8IR4L29Q/KahtZBZb7atRqtnzAs3BERoXcTfRWGEQKzCgJA5d68TwYWQmoOm6Aq// m1/gS2KZfcPbULQ+Ibhq6z8LAicYeFkAjQ2Il+ZJf9Mw6qIW1x7vRtxdXQNhqPPB5Udj aJc6feZ52jJ4U4V3RS1o7GHLJscWUm9wWJeoYTYDLKBuf5Z+MVL4XpueklXDqcdDodqY EFn/5+Qw2ZrzNjIWZiD8MgVN39vM6kwntqEXvS71+d4xKIVEKTF9PgA6ttFgBArcbiZ6 ufngdGQbQmIyWX83dvOEjFoZxsmb9uKKopwZapxFRtjWQ7FEgFsnYEpPixjIfHYqNVFW id7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zmUj4DpYEilReoJCxrU2G2EHiNs3JYMLfA/ozoU+osA=; b=IJ0g2gBIv+aken7w0IaAbNDM/kp1QhH9M6CGkqXugGO3IbJ7m3tBN28pzlYqtU/Q4N w4nN3bqcdTztpZBTTeBqnffd0Xa60iA12KDQQgRiBCpGIvmyMPzfc4WIWcVpv2aYCkvv DbzCj06F4/AhcSYK/8vjBzV6WXdrs0KMYq6RexMwgEsnx8HTKxaJfOUn6uZUODYo1lUF uY/ENRyoMQ1itYCU2C582iwdmwp8MkEOjGfGr9+/iot16MmDEyFheBySd6dOZNQD/kIn oLKqVQqS4FqFMBRHMwvG3W/S07PkF5QUKGJCEgZhrlq/5eaC6KgM6ETGEbI2c/qgc/fa eFmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k2VD6Bgw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17si5796097edc.6.2019.11.14.19.21.07; Thu, 14 Nov 2019 19:21:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k2VD6Bgw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726988AbfKODTz (ORCPT + 99 others); Thu, 14 Nov 2019 22:19:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:37268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726491AbfKODTz (ORCPT ); Thu, 14 Nov 2019 22:19:55 -0500 Received: from localhost (unknown [104.132.150.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1258C206F4; Fri, 15 Nov 2019 03:19:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573787994; bh=X4dYlN8jycxk7zQtoFd/+f0G72lvDqeGK30npKrQ4EY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=k2VD6Bgw3J5MR11pZihhZ/NmF4+UVPdGxF2xOanlIJD6yhXpfGArzODu1jEaJcZxD a8nxXL3a23P6xmA9c/wTwHQm8PVg6OBoGSIslb6e+evXQ4T+c+AS2aF25435pF0RJe oM8isZ0lqZmzVxtDimIoMXRLH/OJnvyWS4DcSLno= Date: Fri, 15 Nov 2019 11:19:51 +0800 From: Greg Kroah-Hartman To: Andrey Konovalov Cc: USB list , LKML , Alan Stern , Jonathan Corbet , Felipe Balbi , Dmitry Vyukov , Alexander Potapenko , Marco Elver Subject: Re: [PATCH 1/1] usb: gadget: add raw-gadget interface Message-ID: <20191115031951.GA793701@kroah.com> References: <282c5da077ad53ce4e5ff9b4350bbf62b33bb6a9.1573236684.git.andreyknvl@google.com> <20191108211745.GA1282512@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 14, 2019 at 04:08:29PM +0100, Andrey Konovalov wrote: > On Fri, Nov 8, 2019 at 10:17 PM Greg Kroah-Hartman > > > +static void gadget_unbind(struct usb_gadget *gadget) > > > +{ > > > + struct raw_dev *dev = get_gadget_data(gadget); > > > + unsigned long flags; > > > + > > > + if (WARN_ON(!dev)) > > > + return; > > > > Why warn? How can this happen? > > This shouldn't happen and I initially had BUG_ON there, but checkpatch > complained. I can use BUG_ON of leave it as WARN_ON, which would you > prefer? If it should never happen, then why test it? If it can happen, then just test and print an error, why panic the machine if panic-on-warn is enabled for something that we can test and recover from? And no, never add BUG_ON please. > > > +static int raw_open(struct inode *inode, struct file *fd) > > > +{ > > > + struct raw_dev *dev; > > > + > > > + dev = dev_new(); > > > + if (!dev) { > > > + pr_err("failed to created device"); > > > > So many error messages printed on failures, you only needed the original > > one if memory was gone that the core sent out. > > What do you mean by the original one? I see only one error printed in > case dev_new() fails. However I'm not sure if there's much value in > printing an error in case the kernel ran out of memory, as it doesn't > handle this very well anyway AFAIK. Should I remove this pr_err? Yes, please do. thanks, greg k-h