From patchwork Sat Dec 10 09:01:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 13070276 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BB4AC10F1B for ; Sat, 10 Dec 2022 09:05:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230045AbiLJJFZ (ORCPT ); Sat, 10 Dec 2022 04:05:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229949AbiLJJDh (ORCPT ); Sat, 10 Dec 2022 04:03:37 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C52371A391; Sat, 10 Dec 2022 01:03:31 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id u5so7193909pjy.5; Sat, 10 Dec 2022 01:03:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Fbmtr+iu05G8hE8+xl0zyODEJYTrkuIzNhZByD6qtnU=; b=UgzLWMXzuwLLSAvD3KHkxw0Bw89627SDEXoKyGTUeeML2rh1RnKO4wDuj3np4KehRh gbavZMR6IMWyNrOyBD3I6w3lEqDVKQCG8GUZGBrpuqvYECsIy+ZYEHwU95f0ezAzP5fv yF6WOlLlP2kIgwoKQBpKVizodDklO8bZ8GDcyAdIUNYygfxi6Zf+ne7vWUbL00IiDHdE 5XalkUklF4SWXQ1dBsARtlGDm6i//q1t0YA9kJ6CBNVfS/6UxR2tB4VIXUfFiadNuAMQ 6A3aPWcixahKkvE5ulLgEXMN89Z7v6dmsKPfg7Nc0xj0bMY7oYa8L6LOsUYf/mqOb0FN Nvyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Fbmtr+iu05G8hE8+xl0zyODEJYTrkuIzNhZByD6qtnU=; b=3KQvLBLW0Yarpz1XjvIoxdagUgGkpjzde9mpgvYciB+LItaXHRmCIAA4BZrsq5fsq3 OPKB2T/sbiBTksyhXDMwXiWzbHY2VjaXicfryub31IRXOtIctYeP9uPQJnX4HZ71R3yp 3KbQM6nJ7vMWLe6l1T2dURLpJYiyUPXORJNOrLsAH1x1PwgzDwcyCmeGKMRtSiz9BWtH 4yXCskq+F4TPvL3jACM4YOX1Zojuue69Y6NZ1cIzxPqmL6luWwiOh9SHQnA/n7rWUQq/ NoSRo2X392mYK7rV8PyfYr3ibssG49cfdzkV7R0xjctJt3cJ4c9rM4GeA7r06fre0aq4 dXew== X-Gm-Message-State: ANoB5pk60McBjFvt9qzl+TcW9vFk4ExsN4a/5Zct544nhtZ4QeY/F4BX ksWLGLInElZTu9a5aaO+UT8= X-Google-Smtp-Source: AA0mqf51A0TZNJaaVYc00wBlbOrjqA1IBl3NJL6KTcsIV7XAYX+HxOIZ2l4Pt/lnCZ/U0cgPYIauIg== X-Received: by 2002:a17:903:41c5:b0:189:cec6:7ac5 with SMTP id u5-20020a17090341c500b00189cec67ac5mr12370330ple.44.1670663011217; Sat, 10 Dec 2022 01:03:31 -0800 (PST) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id u7-20020a17090282c700b00186a2444a43sm2549481plz.27.2022.12.10.01.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Dec 2022 01:03:30 -0800 (PST) Sender: Vincent Mailhol From: Vincent Mailhol To: Marc Kleine-Budde , linux-can@vger.kernel.org Cc: Oliver Neukum , Wolfgang Grandegger , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Frank Jungclaus , socketcan@esd.eu, Yasushi SHOJI , =?utf-8?q?Stefan_M=C3=A4tje?= , Hangyu Hua , Oliver Hartkopp , Peter Fink , Jeroen Hofstee , =?utf-8?q?Christoph_M=C3=B6hring?= , John Whittington , Vasanth Sadhasivan , Jimmy Assarsson , Anssi Hannula , Pavel Skripkin , Stephane Grosjean , Wolfram Sang , "Gustavo A . R . Silva" , Julia Lawall , Dongliang Mu , Sebastian Haas , Maximilian Schneider , Daniel Berglund , Olivier Sobrie , =?utf-8?b?UmVtaWdpdXN6IEtvxYLFgsSFdGFq?= , Jakob Unterwurzacher , Martin Elshuber , Bernd Krumboeck , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alan Stern , linux-usb@vger.kernel.org, Vincent Mailhol Subject: [PATCH v2 6/9] can: ucan: ucan_disconnect(): fix NULL pointer dereference Date: Sat, 10 Dec 2022 18:01:54 +0900 Message-Id: <20221210090157.793547-7-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221210090157.793547-1-mailhol.vincent@wanadoo.fr> References: <20221203133159.94414-1-mailhol.vincent@wanadoo.fr> <20221210090157.793547-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org ucan sets the driver's priv data to NULL before waiting for the completion of outsdanding urbs. This can results in NULL pointer dereference, c.f. [1] and [2]. Remove the call to usb_set_intfdata(intf, NULL). The core will take care of setting it to NULL after ucan_disconnect() at [3]. [1] c/27ef17849779 ("usb: add usb_set_intfdata() documentation") Link: https://git.kernel.org/gregkh/usb/c/27ef17849779 [2] thread about usb_set_intfdata() on linux-usb mailing. Link: https://lore.kernel.org/linux-usb/Y4OD70GD4KnoRk0k@rowland.harvard.edu/ [3] function usb_unbind_interface() from drivers/usb/core/driver.c Link: https://elixir.bootlin.com/linux/v6.0/source/drivers/usb/core/driver.c#L497 Fixes: 9f2d3eae88d2 ("can: ucan: add driver for Theobroma Systems UCAN devices") Signed-off-by: Vincent Mailhol --- drivers/net/can/usb/ucan.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/can/usb/ucan.c b/drivers/net/can/usb/ucan.c index ffa38f533c35..429b3519ee7f 100644 --- a/drivers/net/can/usb/ucan.c +++ b/drivers/net/can/usb/ucan.c @@ -1579,8 +1579,6 @@ static void ucan_disconnect(struct usb_interface *intf) { struct ucan_priv *up = usb_get_intfdata(intf); - usb_set_intfdata(intf, NULL); - if (up) { unregister_candev(up->netdev); free_candev(up->netdev);