Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1186760rdg; Fri, 13 Oct 2023 12:59:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzsCity4ql33nyoGrBoLnRRnLHS+0OdFAdXnTMBOyrdVUboTyoktfWHChmoAOypc7BlqlX X-Received: by 2002:a05:6a00:ccd:b0:68b:e29c:b61 with SMTP id b13-20020a056a000ccd00b0068be29c0b61mr29691283pfv.19.1697227141132; Fri, 13 Oct 2023 12:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697227141; cv=none; d=google.com; s=arc-20160816; b=B4SxDjgP/EC01izNhjqZgsd5rqoOC8tnN/HoKSch/HeIaylBC85F7G/BhAi84bS1qD nzADOOZ9Y1P2Y2RnqMqQKyGgCX6sFEbQQzl9fMOccKUAQ3xhRbsLE+qs9TZp1N7RLsLH 6mLek5AVFNfSWyrIrAkUp9MSWzsiJVhZ7rV5lnIAorl/tPku2pmab2THrQ8csTKpzPN+ uVvpF9YVFWK5wNQygUvLVgF8nEAx4C90DGO6H+AmneU0uHTe3EiNhmPTH5iylU35yX31 sP/HuSAO1uzhn6naTPuxHZ4eDXbm9Y2iPti7QBe8ryAfT336kcVtMGZV0jPY3JUmvyLk 6BUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=3v2MZnD4+Bv2IF4yOo/uMJrqOep8lrhCotYqSu8S8Wg=; fh=H+CeqzBTxSJtf476pMyEaH2YzjNEelexsJvEcIGTHP0=; b=aYZNloToD2sxR+kZuxI//rx9II+78bkoVi1dahfGyafvT1loftAZ5zRNZI32Pyl/Pf 7u5J/6CLsohUODiy0eLgR7LpfZ/ZMcX+XVz91uAJvzeFi8GR7D7ALeCGevMgaEULKhil SfmoxOoTsCzHeER1SWSjSXhLbx5nTt6Mr1mSR0xgN7uHjSdOFckhXg+tuNKljamTXA2z jvoa/MmDGmqpaV/t/x1joRSn/jvu/j3M0V9IEpCMAwmUpU4i+o2KoKCuflghZ/ZxMDJp vgCBfPxT2Q6Csm2J+zvuwsJpc6d5bIaGR/e43blRjVEuXTu592uR5ADnJjiZo6Lcct2l jU8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l1stEPS2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id s21-20020a056a00195500b0068e3b121545si18177339pfk.58.2023.10.13.12.59.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 12:59:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l1stEPS2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 99F7D834AF53; Fri, 13 Oct 2023 12:58:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231846AbjJMT62 (ORCPT + 99 others); Fri, 13 Oct 2023 15:58:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231878AbjJMT61 (ORCPT ); Fri, 13 Oct 2023 15:58:27 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B2ECCE; Fri, 13 Oct 2023 12:58:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697227105; x=1728763105; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=bgfmh1ZnunbqsvNWTPsxu1umgXA01kRIlA1XHogR3lc=; b=l1stEPS2OFmNIm1INCLSeTGRlWwDTPJTzxhWWb68XP5NquEdKWQOEco+ zMlYfAmamlnqElUt+t0M/sx6IBnpWnUj66NE4EqCLgMVKFf9JJpDStaZh sJxXfR76s8waoniIGGR3o91BUdYfYEs6mF63tQmhycFEC8Pds2l3hPCsD V6KFEyMy0ZSnP7vhJKXHSV/GgxbcKlWSyaHKPyqqACcfCXKaGUsE7crrc MQbKEL0njU+LWoodlp9aweTDQJOQjFlLUzgD50BOSXa12PwIc2UUNajhe tgVEqM+L62P1SCoiZH61chBCBAhp3tpzRdOShkr4cqRKPkplltmU+56tQ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10862"; a="3861467" X-IronPort-AV: E=Sophos;i="6.03,223,1694761200"; d="scan'208";a="3861467" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2023 12:58:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10862"; a="845599505" X-IronPort-AV: E=Sophos;i="6.03,223,1694761200"; d="scan'208";a="845599505" Received: from unknown (HELO smile.fi.intel.com) ([10.237.72.54]) by FMSMGA003.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2023 12:58:05 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97-RC1) (envelope-from ) id 1qrOIM-00000005JuR-3tMn; Fri, 13 Oct 2023 22:58:02 +0300 Date: Fri, 13 Oct 2023 22:58:02 +0300 From: Andy Shevchenko To: Hongren Zheng Cc: Shuah Khan , Greg Kroah-Hartman , Valentina Manea , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, sfr@canb.auug.org.au Subject: Re: [PATCH -next] usb/usbip: fix wrong data added to platform device Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 13 Oct 2023 12:58:58 -0700 (PDT) On Fri, Oct 13, 2023 at 06:52:09PM +0800, Hongren Zheng wrote: > .data of platform_device_info will be copied into .platform_data of > struct device via platform_device_add_data. > > However, vhcis[i] contains a spinlock, is dynamically allocated and > used by other code, so it is not meant to be copied. The workaround > was to use void *vhci as an agent, but it was removed in the commit > suggested below. > > This patch adds back the workaround and changes the way of using > platform_data accordingly. ... One more thing... > static int __init vhci_hcd_init(void) > { > int i, ret; > + void *vhci; > > if (usb_disabled()) > return -ENODEV; > @@ -1522,10 +1522,11 @@ static int __init vhci_hcd_init(void) > goto err_driver_register; > > for (i = 0; i < vhci_num_controllers; i++) { > + vhci = &vhcis[i]; This should be void *vhci = &vhcis[i]; because otherwise we mix code and definitions which is not so good style. (Yet we allow to do that in exceptional cases: 1) iterators in for-loops, and 2) RAII allocations with __free() in use.) > struct platform_device_info pdevinfo = { > .name = driver_name, > .id = i, > - .data = &vhcis[i], > + .data = &vhci, > .size_data = sizeof(void *), > }; -- With Best Regards, Andy Shevchenko