Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp373737rwn; Thu, 8 Sep 2022 03:02:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR7+F5E6pkJjjLk2E9NWYkWZQjKmEKXbJsma36Q11ejQzRU36CN8BzlBbytnNUTPp1ikwjx8 X-Received: by 2002:a05:6402:350b:b0:43e:f4be:c447 with SMTP id b11-20020a056402350b00b0043ef4bec447mr6616133edd.427.1662631343555; Thu, 08 Sep 2022 03:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662631343; cv=none; d=google.com; s=arc-20160816; b=wRMryk1MZBd50RN/To9Oj5K4MJ84sX+7ATJsxPKgGqz2VA+mAbVfobqx3bgEKGPgAQ AdUY+A3vWBYiZBm9vVBC/P4wLlOX9lIqZ+Y64ARgVkxPkRv1X4l80o7+pqR9dDaCdu/M 6wuGAGbFZCuQkf/8gKVRdsFMDWpTSuV+IzBOQ5zRLPcyDZHuzXfqI7MKLopk2yycZbxo MP6V8FQZm/VrHRT0xx1xemnblkkhQSXI4nzwQC/ExwI3Bf5q/ZFJi8hGK4c+hWPfiWYn ZCD8F/V8nFEBpTocN3YZEKWvwdKMG51ooj/WirvrYxJVud1+MQbG7LPeht6QT4aR43PB bbTw== 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=MFrqvGzeWUMBgRnnt6RmzgBnVbJb1zQ0TJYrr0s+8lU=; b=cFKcIlt8IzWZxP9kjQVsoCRcWZGHk27gsFGrpW/PvKx0ZyPhb+8iGOxSThdrxGKuME PWoyfdEffUPIfGbULzB2kU5wBF0bWGI04cVZ4DEDLRty5RYBnKmEOq4y9U48Rzof6gl+ ssWIScf7p+DWcDWharKn98xUFeYOW2K5n4Gkqi3DYnZsvBcASRqaFha0gu4OyYntIcWl Jp6Pt1zVMzuHV9OgadIFJeRAUYSX0KNpvOEV6o+99om6Vgdwsw0n+TG1lwReL9La8nVE KcKSxUt3Zj9TU/gdjFQdt40ylvgNwaVGJEOzYpjqwfpNs7RI9t291wlEEUiqJ65tYc8+ yWgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=vgEDl6jJ; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=ooGGzh4R; 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 p9-20020a170906a00900b007316ac034a1si1351346ejy.831.2022.09.08.03.01.58; Thu, 08 Sep 2022 03:02:23 -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=vgEDl6jJ; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=ooGGzh4R; 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 S231472AbiIHJvw (ORCPT + 99 others); Thu, 8 Sep 2022 05:51:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231343AbiIHJvZ (ORCPT ); Thu, 8 Sep 2022 05:51:25 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 038D8129507 for ; Thu, 8 Sep 2022 02:51:21 -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-out2.suse.de (Postfix) with ESMTPS id 4FD371FA4C; Thu, 8 Sep 2022 09:51:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662630680; 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=MFrqvGzeWUMBgRnnt6RmzgBnVbJb1zQ0TJYrr0s+8lU=; b=vgEDl6jJcnaySeYrOHeQGUSjY/L4zpNu7IoatoSQCW98y7LHzZHUOsy6nrvgtuZIIqIaKi IhhovfemfHYoXNoUE1Kkyl821GD9vdsyJw0RABZ8qrOX2XwEVEQpS3UuIqGceuEZfIkhfS egj7jYX1OyiqG4aJxpbiLaMgPy7cfZ8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662630680; 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=MFrqvGzeWUMBgRnnt6RmzgBnVbJb1zQ0TJYrr0s+8lU=; b=ooGGzh4RQfhg65bUd/uswlxHFGkiLnbz2SGgHT+P5KcJEBqfauREOhCMCD3Ly4rPLF7yu9 m7aGiCE81rgwVkAA== 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 2F3EC13A6D; Thu, 8 Sep 2022 09:51:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uGLuChi7GWNrUgAAMHmgww (envelope-from ); Thu, 08 Sep 2022 09:51:20 +0000 From: Takashi Iwai To: Thomas Zimmermann Cc: Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 09/12] drm/udl: Fix potential URB leaks Date: Thu, 8 Sep 2022 11:51:12 +0200 Message-Id: <20220908095115.23396-10-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220908095115.23396-1-tiwai@suse.de> References: <20220908095115.23396-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()") Acked-by: Thomas Zimmermann 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 2b7eafd48ec2..de28eeff3155 100644 --- a/drivers/gpu/drm/udl/udl_main.c +++ b/drivers/gpu/drm/udl/udl_main.c @@ -260,11 +260,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