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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA1CEC433FE for ; Tue, 22 Nov 2022 15:54:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232625AbiKVPyW (ORCPT ); Tue, 22 Nov 2022 10:54:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234076AbiKVPyI (ORCPT ); Tue, 22 Nov 2022 10:54:08 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D286725C6 for ; Tue, 22 Nov 2022 07:54:07 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E5B966174C for ; Tue, 22 Nov 2022 15:54:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC90DC433D6; Tue, 22 Nov 2022 15:54:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669132446; bh=X6PdGbPkJr/uQ/4I5ASpX/0XLwGdDXxq5tPCLjd+gu4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=d0sL9NISCvodfJKi0nkKaSGPw6wOPtZpVemN8nLIfeQR3dKW9MzsKaxFAaqb3kEUI Wx+v9TTZW5i2NCY906j1UTgl66ug/RJCXaH/GSz/znydSqIOpbLCSskJQRcu0F81F9 neraGekfvxAqhdIrKJPJKpoVZPE09O5KonvVEhQs= Date: Tue, 22 Nov 2022 16:54:03 +0100 From: Greg Kroah-Hartman To: Andrzej Pietrasiewicz Cc: linux-usb@vger.kernel.org, kernel@collabora.com Subject: Re: [PATCH] usb: gadget: function: Simplify error messaging in printer open/close Message-ID: References: <1894a272-4816-c44c-61d5-bfcfe478d7e5@collabora.com> <20221122141603.70242-1-andrzej.p@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221122141603.70242-1-andrzej.p@collabora.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Tue, Nov 22, 2022 at 03:16:03PM +0100, Andrzej Pietrasiewicz wrote: > Don't issue any messages if printer_open() is successful. > Also don't issue them if unsuccessful - the error code is propagated > to the calling layers and should be acted on appropriately there. Just as > it is with the -ENODEV case. > > For those who really want this message leave an option to compile-in > with composite framework's VDBG() by uncommenting #define VERBOSE_DEBUG. > > While at it, visually detach the "return ret;" statement. > > Use __func__ instead of explicitly hardcoding the function name. This, in > turn makes checkpatch issue this for the message in printer_close(): > > WARNING: Unnecessary ftrace-like logging - prefer using ftrace > 54: FILE: drivers/usb/gadget/function/f_printer.c:387: > + VDBG(dev, "%s\n", __func__); > > which lets us eliminate the debug message from printer_close() altogether. > > Signed-off-by: Andrzej Pietrasiewicz > --- > Attention > > This patch depends on a recent patch from Dan Carpenter: > > usb: gadget: function: use after free in printer_close() > > drivers/usb/gadget/function/f_printer.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c > index 01e842e1ba2f..d686c7be4fb5 100644 > --- a/drivers/usb/gadget/function/f_printer.c > +++ b/drivers/usb/gadget/function/f_printer.c > @@ -11,6 +11,8 @@ > * Copyright (C) 2006 Craig W. Nadler > */ > > +/* #define VERBOSE_DEBUG */ > + > #include > #include > #include > @@ -364,7 +366,8 @@ printer_open(struct inode *inode, struct file *fd) > spin_unlock_irqrestore(&dev->lock, flags); > > kref_get(&dev->kref); > - DBG(dev, "printer_open returned %x\n", ret); > + VDBG(dev, "%s returned %x\n", __func__, ret); This is what ftrace is for, please just delete this line entirely. thanks, greg k-h