From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752769AbdLEWVi (ORCPT ); Tue, 5 Dec 2017 17:21:38 -0500 Received: from mailout.easymail.ca ([64.68.200.34]:55630 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752554AbdLEWVd (ORCPT ); Tue, 5 Dec 2017 17:21:33 -0500 Reply-To: shuah@kernel.org Subject: Re: [PATCH 2/2] usbip: Use common error handling code in stub_recv_cmd_submit() To: SF Markus Elfring , linux-usb@vger.kernel.org, Greg Kroah-Hartman , Valentina Manea Cc: LKML , kernel-janitors@vger.kernel.org, Shuah Khan , Shuah Khan References: <6a84f1e4-a5c1-84da-bd14-de28e306991b@users.sourceforge.net> <32b1d0d7-8a48-a960-c666-b0ea187ecdcc@users.sourceforge.net> From: Shuah Khan Message-ID: <226643ef-2f5b-49db-cabe-97e2f727f9bc@kernel.org> Date: Tue, 5 Dec 2017 15:21:19 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <32b1d0d7-8a48-a960-c666-b0ea187ecdcc@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/05/2017 02:52 PM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Tue, 5 Dec 2017 22:40:30 +0100 > > Add a jump target so that a bit of exception handling can be better reused > at the end of this function. > > Signed-off-by: Markus Elfring > --- > drivers/usb/usbip/stub_rx.c | 22 ++++++++++------------ > 1 file changed, 10 insertions(+), 12 deletions(-) > > diff --git a/drivers/usb/usbip/stub_rx.c b/drivers/usb/usbip/stub_rx.c > index a70eb81823a3..f46d71abd2f9 100644 > --- a/drivers/usb/usbip/stub_rx.c > +++ b/drivers/usb/usbip/stub_rx.c > @@ -445,29 +445,23 @@ static void stub_recv_cmd_submit(struct stub_device *sdev, > else > priv->urb = usb_alloc_urb(0, GFP_KERNEL); > > - if (!priv->urb) { > - usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC); > - return; > - } > + if (!priv->urb) > + goto add_event_malloc_failure; > > /* allocate urb transfer buffer, if needed */ > if (pdu->u.cmd_submit.transfer_buffer_length > 0) { > priv->urb->transfer_buffer = > kzalloc(pdu->u.cmd_submit.transfer_buffer_length, > GFP_KERNEL); > - if (!priv->urb->transfer_buffer) { > - usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC); > - return; > - } > + if (!priv->urb->transfer_buffer) > + goto add_event_malloc_failure; > } > > /* copy urb setup packet */ > priv->urb->setup_packet = kmemdup(&pdu->u.cmd_submit.setup, 8, > GFP_KERNEL); > - if (!priv->urb->setup_packet) { > - usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC); Please see comments on my comments on the previous patch in this series. This patch depends on the patch that is incorrect. > - return; > - } > + if (!priv->urb->setup_packet) > + goto add_event_malloc_failure; > > /* set other members from the base header of pdu */ > priv->urb->context = (void *) priv; > @@ -507,6 +501,10 @@ static void stub_recv_cmd_submit(struct stub_device *sdev, > } > > usbip_dbg_stub_rx("Leave\n"); > + return; > + > +add_event_malloc_failure: > + usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC); > } > > /* recv a pdu */ > I am restructuring this routine to fix a bug and so it stands now, I don't see a value in taking this patch that doesn't really fix any specific bug. thanks, -- Shuah