From patchwork Sat Dec 3 13:31:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 13063534 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 2C79FC4708E for ; Sat, 3 Dec 2022 13:33:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229876AbiLCNdw (ORCPT ); Sat, 3 Dec 2022 08:33:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229835AbiLCNdY (ORCPT ); Sat, 3 Dec 2022 08:33:24 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CE551EAF7; Sat, 3 Dec 2022 05:32:53 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id r18so6599632pgr.12; Sat, 03 Dec 2022 05:32:53 -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=eF9XShE5TJVkfnfRnJlkYlYYSsfKbTDmFNqULVnSW+E=; b=qCVa8HcyTJPvaxUsBydSGsuhXbxjTWPrYKA/b2wF5kUy0UWg5wRLqjNL6rZRlwxX8e v0EZNF6FPAzyLIMGqfxKiVhMlIjtKA5LNEq7y2/kdNto4pklx7bsgbRVf9F3FAjBAXgQ eq/B5hKXAxVkyzE0m44vtQEfgxYszsH4bVXJS+QP5DP6gJqLX0HTUVqUviOJcIOUCTO4 8F4hn39Oe+zSWsV+DDxiA0+1lQcyjlviSXn2Rz0NSjy9R8SyQCTts6Xmzwx9qhHsBLFX mG7EVUWVSTbZ+xVrmhSmXkZnqJaUnD5P0LquuSB0pMDnsSG0W6ovLs93/B3JxWWPFAWN LUzQ== 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=eF9XShE5TJVkfnfRnJlkYlYYSsfKbTDmFNqULVnSW+E=; b=V7P0EsyiFwO2YIuHHgOJysa8OO8qRnKJ7gtgRQEXBkiqBcNM9WX1InJxteNgmjpfYR +42I7YlKz3CDm+xS2VfkX+nBFdm/BhruQhGPiSvjSboqNlwJ1wMdH7JUFJvD2d1Quicw 6wUoewTTmlfdI+1wY/RJNJ9E8ekNq4Y17w/IK+MkyfXumUaPCLHYLaHE/RC8YtEoMdz4 lhZZ3G7nKYqt+ilqDgq+KZJbS89bfZs4AOPJOOI+gGfGir505/QRgbg8tT47lMH+hhl1 XyBETm2dxcGcqwpzbP4ReL47+PD2XsMwvSaXskCzJIovoRuckizyaTDxmeBOYGhZj9u3 dQbg== X-Gm-Message-State: ANoB5plhTviFBVQ/g53llBT1zCis5xgIVUgFP10/R2NU0N7WN6Sy7mE1 +j50FEsNwPkgvB2H6512dbM= X-Google-Smtp-Source: AA0mqf6yBRx7vd+hKPw5cCnOi+O438dLHdlH19SDLTH0Wupse3Q+/hj/PAxljBNAtn/pnWlxhiJwXg== X-Received: by 2002:a05:6a00:1624:b0:573:993b:ea6d with SMTP id e4-20020a056a00162400b00573993bea6dmr58237780pfc.10.1670074372733; Sat, 03 Dec 2022 05:32:52 -0800 (PST) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id q12-20020a170902dacc00b00185402cfedesm7414472plx.246.2022.12.03.05.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Dec 2022 05:32:52 -0800 (PST) Sender: Vincent Mailhol From: Vincent Mailhol To: Marc Kleine-Budde , linux-can@vger.kernel.org Cc: 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 , Philipp Tomsich , Bernd Krumboeck , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alan Stern , linux-usb@vger.kernel.org, Vincent Mailhol Subject: [PATCH 5/8] can: mcba_usb: mcba_usb_disconnect(): fix NULL pointer dereference Date: Sat, 3 Dec 2022 22:31:56 +0900 Message-Id: <20221203133159.94414-6-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221203133159.94414-1-mailhol.vincent@wanadoo.fr> References: <20221203133159.94414-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 mcba_usb sets the usb_interface to NULL before waiting for the completion of outstanding urbs. This can result 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 mcba_usb_disconnect() at [3]. [1] commit 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: 51f3baad7de9 ("can: mcba_usb: Add support for Microchip CAN BUS Analyzer") Signed-off-by: Vincent Mailhol --- drivers/net/can/usb/mcba_usb.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/can/usb/mcba_usb.c b/drivers/net/can/usb/mcba_usb.c index 47619e9cb005..a21c1ad4894f 100644 --- a/drivers/net/can/usb/mcba_usb.c +++ b/drivers/net/can/usb/mcba_usb.c @@ -890,8 +890,6 @@ static void mcba_usb_disconnect(struct usb_interface *intf) { struct mcba_priv *priv = usb_get_intfdata(intf); - usb_set_intfdata(intf, NULL); - netdev_info(priv->netdev, "device disconnected\n"); unregister_candev(priv->netdev);