Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1383180ybk; Thu, 14 May 2020 07:41:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyF5bE1ZuvVKUQGvTBHK7w4kILHNU1DoJpJdph54DPzUqmcwBJwTNCYuap+Y4bGaLO7qLwN X-Received: by 2002:a50:f057:: with SMTP id u23mr4230715edl.238.1589467295052; Thu, 14 May 2020 07:41:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589467295; cv=none; d=google.com; s=arc-20160816; b=a7NxXGwAidCfvUZb8pKFkKXacRvzgTIfRW3NReZ0kcHWmk/YzX8vOd9if1Auuw+2Bo I2HJJAUgWgFDB5L9LHCEKFsfkeDDhGK9y5M4JQf1BLBBbvprcvFBDEqwbiCzhGrNNax/ ReRn4vYhVl0rAsTEHMpEDUuQoLp3lHp71HMA2IeHPUVLMFUnMZyZEHTcjNt031leYxNC Omxtl72q59wMTMJ0XEbO/f/fBF4qKtQ1IuHNsOke3eDcZNZytZ6hHMc54H+6SBKI7Cnj 522eBVQgDC61RDzrD4ZO7HEVNEnIQKi2aq2iO811b1eA6TH1H+sjT+H61h2mbt7GiFFd XxRw== 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; bh=SJJbYsFg47HnibjvxrXsQq1bVW6juLxVt907z+oS7Qs=; b=W/7QFYRmoqsiD8zRFMNvT0g6f1qy1fJu68TNFmVBkHhBKU10OrTzXz/DO5ChtTaf65 XFnWYgz+F4bjF4kXemznCi6LKFFIvgLUyjFROb5D9i/clNv5Qpwmjik2DNwJeJHIrWpT QjT8aZIWmbbbhoBihyV0BEePMo0X2khjb98FyYSosQ2WsNxHLaAFgfun1vPIzRHbu9KF ZaX6rA4WnGXRQUtCC3m+CJ7fKafsN5NSLTwl0SFV6tiXrotO5Yja7kIXKvioosyjvmQV beBAX5hDNJsyN5R7X5py9hmHSoybf6AN0ZddXRyKaVohIfTfT6Vvh0o9cYBH2xcDNe58 57UA== 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 h26si2057686eja.132.2020.05.14.07.41.10; Thu, 14 May 2020 07:41:35 -0700 (PDT) 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 S1727896AbgENOjR (ORCPT + 99 others); Thu, 14 May 2020 10:39:17 -0400 Received: from verein.lst.de ([213.95.11.211]:52180 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbgENOjR (ORCPT ); Thu, 14 May 2020 10:39:17 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id CC6FD68BEB; Thu, 14 May 2020 16:39:13 +0200 (CEST) Date: Thu, 14 May 2020 16:39:13 +0200 From: Christoph Hellwig To: Greg Kroah-Hartman Cc: Christoph Hellwig , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Hillf Danton , Thomas Gleixner , Jeremy Linton , syzbot+353be47c9ce21b68b7ed@syzkaller.appspotmail.com, stable Subject: Re: [PATCH] USB: usbfs: fix mmap dma mismatch Message-ID: <20200514143913.GA27798@lst.de> References: <20200514112711.1858252-1-gregkh@linuxfoundation.org> <20200514115829.GA15995@lst.de> <20200514120944.GA2005274@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200514120944.GA2005274@kroah.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 14, 2020 at 02:09:44PM +0200, Greg Kroah-Hartman wrote: > > > + if (dma_mmap_coherent(hcd->self.sysdev, vma, mem, dma_handle, > > > + size)) { > > > + dec_usb_memory_use_count(usbm, &usbm->vma_use_count); > > > + return -EAGAIN; > > > + } > > > > What about a goto label to share the error handling path? > > I thought about that, but that's a bit messier than the duplicated lines > here :) Actually the error handling looks weird, we can just use normal unwinding here with an extra call to usb_free_coherent. Also -EAGAIN is a strange error to return in this case, as it is simply incorrect. I think passing through the errors from dma_mmap_coherent and remap_pfn_range would make a lot more sense. Last but not least I wonder if this is the right place to open code the localmem and has_dma checks - from a layering POV it should be a usb_mmap_coherent helper at the same level as usb_alloc_coherent.