Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3788742rwb; Tue, 16 Aug 2022 08:47:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR6lexks0vzHq+vXFzAm18jpcyAUcTMt0vvahTKAtHP9PBC7FULk7rNtpR7PCzHfSt8tYSJJ X-Received: by 2002:a17:906:98d4:b0:730:b545:fb5d with SMTP id zd20-20020a17090698d400b00730b545fb5dmr13573879ejb.532.1660664841584; Tue, 16 Aug 2022 08:47:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660664841; cv=none; d=google.com; s=arc-20160816; b=RaHtne7kAUIE7wEVt3ulRoD7JGqm8c1saikD49SPc56Z/NyFEXhbZAClMUMieMVQIp iQIW8dQiROomk6HcRzLx14cI5XdEfrG3BRH93l7+IpLOUgnxaF++cVQP23d0t3PNxbsF zrNYhHjMB9849NkIrmfT2SpFEbP7ePkisVpSi7JwJJBdFPegnBh8cqgq2sLISYkWTYOQ 5sFTWIFIIOCVJGyNN8Rfyj35cleuQXcd2t2n2eD5HsAD9lEykuLLZ/0prtXON+6hKbum qN+ssNPt8+LE2BapMs4OWExns/3EoYu9TT5HkO4QGT4Gxl1BrMkbYMbDOeAyA7WWmNzF bXpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=9s6v1CY1qexUT4c1xbug4TQo33VinY3YcP39jbAWYwQ=; b=HbLcfk5WUTFx93+GBrlHLdVmMhe6n6mg7M59utaG9Y49b4bg4+pZRY3t6P6H820O3S uZyWyaGs7gtDbOD+0A0Mr8xe1ok9pQbKVdQ3mxlKvkC3xhjEgXVMlcmVcIjczaiO5wqy qVRrK2dKyg0IpndTbjFm52tsDJSkU9J2op3u0XmmRk7yIUgV6S3rQEJ5mFb2WOvucBNc ZsK5pBR+d3MRl0O2JRN7fcCC8/K9uzNM35EjmDTB8omVkXF+L/s9dnfHGxbZ3JoLCh1a LCFSUTBckZ3S4azfGz8fiuP3n8BOO/zVYdv1p8rWgrD7CFiO/h3X8pdmzCcAzCUh01tc WFLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=gEzA2P8g; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="/Ei/7ZJf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x6-20020a05640226c600b0043be6e20cbdsi10693741edd.23.2022.08.16.08.46.56; Tue, 16 Aug 2022 08:47:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=gEzA2P8g; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="/Ei/7ZJf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236255AbiHPPi7 (ORCPT + 99 others); Tue, 16 Aug 2022 11:38:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236139AbiHPPiG (ORCPT ); Tue, 16 Aug 2022 11:38:06 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED97D85A9F for ; Tue, 16 Aug 2022 08:37:04 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8E52234871; Tue, 16 Aug 2022 15:37:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1660664223; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9s6v1CY1qexUT4c1xbug4TQo33VinY3YcP39jbAWYwQ=; b=gEzA2P8grsErGJsV4EbD2oDgBDLMYTqr1oZk7gzar/Tf/UISsZ+mQpcnAMPyuhZBuasyaF CKepulZlERJ5z6yPZbPKLrf1LJSuqrcdrHx1yFOeLyi0ShuYgYUh1s+w1dXGHlLTqkj1Xa uaSnB2hw81Qt/SW9I/TERNYfs0iPRec= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1660664223; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9s6v1CY1qexUT4c1xbug4TQo33VinY3YcP39jbAWYwQ=; b=/Ei/7ZJfi5ovg5Au2jYmMXv8s6mGBKw5wesen5Yxqv6v8oC7tK7cKuiCNa66FNDzONlTkI Jc4Ooz14QbnDhpDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 705C8139B7; Tue, 16 Aug 2022 15:37:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qFDJGp+5+2LKJAAAMHmgww (envelope-from ); Tue, 16 Aug 2022 15:37:03 +0000 From: Takashi Iwai To: Thomas Zimmermann Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/12] drm/udl: Fix potential URB leaks Date: Tue, 16 Aug 2022 17:36:52 +0200 Message-Id: <20220816153655.27526-10-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220816153655.27526-1-tiwai@suse.de> References: <20220816153655.27526-1-tiwai@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A couple of error handlings forgot to process the URB completion. Those are both with WARN_ON() so should be visible, but we must fix them in anyway. Fixes: 7350b2a3fbc6 ("drm/udl: Replace BUG_ON() with WARN_ON()") Signed-off-by: Takashi Iwai --- drivers/gpu/drm/udl/udl_main.c | 8 +++++--- drivers/gpu/drm/udl/udl_transfer.c | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/udl/udl_main.c b/drivers/gpu/drm/udl/udl_main.c index 3c97f647883f..8bbb4e2861fb 100644 --- a/drivers/gpu/drm/udl/udl_main.c +++ b/drivers/gpu/drm/udl/udl_main.c @@ -265,11 +265,13 @@ int udl_submit_urb(struct drm_device *dev, struct urb *urb, size_t len) struct udl_device *udl = to_udl(dev); int ret; - if (WARN_ON(len > udl->urbs.size)) - return -EINVAL; - + if (WARN_ON(len > udl->urbs.size)) { + ret = -EINVAL; + goto error; + } urb->transfer_buffer_length = len; /* set to actual payload len */ ret = usb_submit_urb(urb, GFP_ATOMIC); + error: if (ret) { udl_urb_completion(urb); /* because no one else will */ DRM_ERROR("usb_submit_urb error %x\n", ret); diff --git a/drivers/gpu/drm/udl/udl_transfer.c b/drivers/gpu/drm/udl/udl_transfer.c index a431208dda85..b57844632dbd 100644 --- a/drivers/gpu/drm/udl/udl_transfer.c +++ b/drivers/gpu/drm/udl/udl_transfer.c @@ -180,8 +180,11 @@ int udl_render_hline(struct drm_device *dev, int log_bpp, struct urb **urb_ptr, u8 *cmd = *urb_buf_ptr; u8 *cmd_end = (u8 *) urb->transfer_buffer + urb->transfer_buffer_length; - if (WARN_ON(!(log_bpp == 1 || log_bpp == 2))) + if (WARN_ON(!(log_bpp == 1 || log_bpp == 2))) { + /* need to finish URB at error from this function */ + udl_urb_completion(urb); return -EINVAL; + } line_start = (u8 *) (front + byte_offset); next_pixel = line_start; -- 2.35.3