Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4049149rwb; Tue, 6 Sep 2022 01:28:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR5nUPp7FxdxZMjfC/yWrc3Ylqene8bLMCvCU01dwrdVSfp/WJ5I7/WQoa5eeecair/Ro6a6 X-Received: by 2002:a17:907:2da6:b0:73d:d587:6213 with SMTP id gt38-20020a1709072da600b0073dd5876213mr38081443ejc.5.1662452927667; Tue, 06 Sep 2022 01:28:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662452927; cv=none; d=google.com; s=arc-20160816; b=sTRFu/CNqPjLO14/7FlrBQ81Qzx5fZhXBP2iMOHDJgIWAqil8ygb/uvb01d6gTET4p Eo4DdvN4AzgC9nHBN0cHzuSQBiJA++EIhdGbEljnCzbbv3fGhoGVM8n/CIWqw5k3zhWs kf4zrf1Y/1Hfc/7yBNcZMZzhgo2iVQVbLKFqDhMcvY+XOPr3RIIGa/X3Yaki3FzBXAUJ w0Bn6JnMckYjEdRo504q731omOqr88IizaK2B63dEFAUm1IHh1hBgS7FsMdwOIwrKg7b MyS54dZp36FS6ZTR6H2j9WYYD494BBp6UduIvJwEH5n/pbztF3r9Li1Zf75kDrMFkIEg Mf9g== 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=LAhhTbST40mkyddOmfQD69yI9P5ZBqlJAgZwqounXoS0bYPwGLw44JPRAs/yxgHaLO r/5reYrI1JpRwBd4ZtEDh1K+g8FPq0IeLiXiz84dfYJ1g7Wv0LXm5rFbpOPaSrSpMz0d jDVvUiFLd86vsXwMyybW67uEAcanHD1in7dqh/Bv5mjxfC7u8yuS11R+DtXmi9CiHB+E rPcVuo0XOHhxKVy72NKpLB8FLWhGI4ITIf/+YRAKeFWXkWgxkczLllx8CUD1Q0H/CXAv nKf2ItTHvHXASC9Qm1k77G1rDMfLV6UkNBtGbmaWwvX/JOpu0z3woy2K3zUPbTZ0eyhL lnKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=YbMMu99v; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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 gn8-20020a1709070d0800b007310a6d6a7esi1344387ejc.975.2022.09.06.01.28.13; Tue, 06 Sep 2022 01:28:47 -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=YbMMu99v; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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 S234024AbiIFHkl (ORCPT + 99 others); Tue, 6 Sep 2022 03:40:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233691AbiIFHj6 (ORCPT ); Tue, 6 Sep 2022 03:39:58 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 252F323141 for ; Tue, 6 Sep 2022 00:39:57 -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 AFDCE1F966; Tue, 6 Sep 2022 07:39:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662449995; 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=YbMMu99v+YQF+axHLa4iY8zCInUofABW6JVreUid+LDTwvG9dnO2cY62V/+NM15HWgAVvM D6LW0mnziREwrkitUYyAJ9BPw61WnUAz7b5YNgBvWs7829PivZ+Tz5DjzNbmqXp7pgO7MS JqggKb8ax6n60UbxAbPHeijtK9KbiJU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662449995; 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=3ERnL2zKHaOh/88VP1Xzb2Bb24VVNPBS4m0jdSEIxK3vNTkXYTzcytevRfG4D0DpT6eZFl nSRzsWQ4jG0ChwBw== 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 932E613A7A; Tue, 6 Sep 2022 07:39:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WMkLI0v5FmPeOgAAMHmgww (envelope-from ); Tue, 06 Sep 2022 07:39:55 +0000 From: Takashi Iwai To: Thomas Zimmermann Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 08/11] drm/udl: Fix potential URB leaks Date: Tue, 6 Sep 2022 09:39:48 +0200 Message-Id: <20220906073951.2085-9-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220906073951.2085-1-tiwai@suse.de> References: <20220906073951.2085-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