From patchwork Sat Dec 10 09:01:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 31992 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1213289wrr; Sat, 10 Dec 2022 01:13:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Js2JZMHwH8MN4Evy/YKvr22ub7BHnyFog8DbxIJ61RsNAsJ9wQ8UbNo6+wHPOOAqU13s/ X-Received: by 2002:a17:902:e952:b0:189:dc3:ee9c with SMTP id b18-20020a170902e95200b001890dc3ee9cmr10402655pll.65.1670663591884; Sat, 10 Dec 2022 01:13:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670663591; cv=none; d=google.com; s=arc-20160816; b=Zo61BJdV9v+WEUaB2lziCzOW5ZIq6VWSG8MVUjRD0xVQ6KZFY37EGKdlxBfTViJ1BM v8IsDgC4QheU+Jc2x2ujrQciosdp8rqiKpsNIFc8Hu1seiFDw56HUv2WIFRMwDiGBg0S rPVAG3hfF/FtLxFXJn13CzPyhD2mDmFX3Z+/oU1e4YRDdRh6lMwYdz1cegkEw6uCF0eb icJ6RjyPgt8HR3NO9dJrIDU7WTL3TS4fqgCn4rXft8VsaJDjEm3XD0hrMj7X2NZdGXZ3 PIbiglMft66BLsggKmpQ0bZljSv66kvRMawvuTrnVCJk8L2aBcboFu+PrDKBQkQ+QhEJ Ngqw== 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:sender :dkim-signature; bh=pa3DAHwWDelaMryXafO6tGBc9UO2GhBo2ljQmz+7iQs=; b=ZJfnDfaRDTAYX5L1KESQylkmtvH9leUhsuBiFRGAtqUCtjMyKRg/W8drNaZGmXV1D0 1/jndLCvVwOYmHae61E+j04ifn5EvN3gGZcLdgoYHXEIqtBzjpX+wqd9Cb7HxjychTvo GK1+KKKPYPjkGYPiQ8QEEMtLTg1pimEk7fLw31wnJ0jmssFIAaT7mRj62uyqF0tVUHTm Oun7RwKWD//3n9BjsQw/GQJ944de3N8/IW6/9nMuUB/oN6SPfCDGH02GDvLwuUjnoAbc iWD+iOsTt/Hz1bxXzqJmchTaz0R5UxZP84Mbf4T7VsxrkdpvrdeV39dLLNUpd5rW4PBD kEWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=M4QXAhvA; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y3-20020a170902700300b0018922404e22si3541118plk.474.2022.12.10.01.12.56; Sat, 10 Dec 2022 01:13:11 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=M4QXAhvA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229952AbiLJJF5 (ORCPT + 99 others); Sat, 10 Dec 2022 04:05:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229897AbiLJJEP (ORCPT ); Sat, 10 Dec 2022 04:04:15 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 116C125EF; Sat, 10 Dec 2022 01:03:39 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id o1-20020a17090a678100b00219cf69e5f0so10654086pjj.2; Sat, 10 Dec 2022 01:03:39 -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=pa3DAHwWDelaMryXafO6tGBc9UO2GhBo2ljQmz+7iQs=; b=M4QXAhvAH2eGt1ylyB64bOaFHwiFc+CBiEpoLnv4v1iGZPuAkFClsRom7OrmYnWnMG wZSKDciH8kf2sSAyO6QAoSUWsulapheuNTWfnUWBpx7ozuE7iolVMdqD178hdqtH6+qL fuKBbxroyOvt+Cpf268JUbrF3nOGNsI7YTTux0KSyf2aFyCobckTe5CtJrHGHGwr9HcH fZjCCjklWCoz6sZen8INjEYsOqRnU1J67OkyJdytUGhd5L2HOlKPd00UKQUe9bf3hwXE jQMR0jq9hI66lwRdhy/zsHxBqrcDfz+5s9gy3lAPiio3YYWGAbhMCFadZppsQTt+/Jng XxDA== 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=pa3DAHwWDelaMryXafO6tGBc9UO2GhBo2ljQmz+7iQs=; b=MuxTGDOCmg4feQKMC7QEpM9yeMqer8QJiZyuy65SyTXo053B5IyMd/5AyJZm+VsO2V RuiBv/MvzjSZ0yjkg4aVrY1+XilP63bNnoNBt7higFYQmTsH7zgVZ2TikwKqJW3UUORU yNltwiPf1XE+npL8Soqy2jyofstu+ZI6EaTug7oblMz9A1fdsAQ+iI38A9TBahGIHma/ 6az7+kVE9WZWw6Ig+7fMXm44Yu8GPWw+jCF6PMGJd3EqhdbbNKKQaj1UBjXTIA8uxOWc EciBixy6NkKboSYw8rW6S8X3GQ6des535UYCbpOPwIVGoSzt8WEfZf091aZEwsk1PT6D Odgg== X-Gm-Message-State: ANoB5pmaYnjRT6uM3TabeMx3upQ9gC/VBVkGaCaBP03P4N4jz0EhN0y5 aKZf9DQgtE+do0nr+RQjNfk= X-Received: by 2002:a17:903:4094:b0:189:7548:20a7 with SMTP id z20-20020a170903409400b00189754820a7mr7429526plc.56.1670663018501; Sat, 10 Dec 2022 01:03:38 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Dec 2022 01:03:38 -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 7/9] can: usb_8dev: usb_8dev_disconnect(): fix NULL pointer dereference Date: Sat, 10 Dec 2022 18:01:55 +0900 Message-Id: <20221210090157.793547-8-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 X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751200124024373633?= X-GMAIL-MSGID: =?utf-8?q?1751817746202120441?= usb_8dev 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 usb_8dev_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: 0024d8ad1639 ("can: usb_8dev: Add support for USB2CAN interface from 8 devices") Signed-off-by: Vincent Mailhol --- drivers/net/can/usb/usb_8dev.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/can/usb/usb_8dev.c b/drivers/net/can/usb/usb_8dev.c index 8a5596ce4e46..ae618809fc05 100644 --- a/drivers/net/can/usb/usb_8dev.c +++ b/drivers/net/can/usb/usb_8dev.c @@ -990,8 +990,6 @@ static void usb_8dev_disconnect(struct usb_interface *intf) { struct usb_8dev_priv *priv = usb_get_intfdata(intf); - usb_set_intfdata(intf, NULL); - if (priv) { netdev_info(priv->netdev, "device disconnected\n");