From patchwork Fri Jun 1 22:58:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 137575 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1508936lji; Fri, 1 Jun 2018 16:00:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIIc3eB1gypeY73zfYkh9eUo39DrTTiDaN3JIhW/WkIOU2v6ro3TU4TsHf94ik/LBJZnYIz X-Received: by 2002:a17:902:f83:: with SMTP id 3-v6mr12732880plz.336.1527894035158; Fri, 01 Jun 2018 16:00:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527894035; cv=none; d=google.com; s=arc-20160816; b=Ur3bM6qhUwOwhTA88esrGDb8ZQ7HDFIBXDiktjOfJPJl8p4/16KPtaW5BBdLLGDzKI AvIx0j6ja9+D5dEY0MDapnAWNr0aBhESExD8kW5CcJ6ipj1ekyEzh9LEv/eEg2RnX0yG lAdRacCfiYjGdkPpViq94h5zEyiSQJCqlnbvEU50q+kNRN1jwT8cHKjLl9jtGDRMNfvF 3w8LXVD7aIxF3u050VQ6S8JZSoDq7/TrSKClgt0yhjLYtCMoG8eRgpjzcPby4q5YZHjj AiE5V1/AZqptq51VH3CfxBQrxBQv507wnCJFpbs8xIO/Lv9Y0T8CFxppyW7Ae1WvI9Cj dKpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=RnyxsRiKXqEzVOJK84NE89XXGO6FtzxEDuHl7u/uGgM=; b=D2nLJTFvcJpg23l3ff1+28rE9rVW/nCe1lJPJ49XVck/PF5LpxoP/jT5OhwkwUiUwS uHN+bGjxU6F2/p4o38irE6BiLUOe3r7EEoxUdYJgZSj6+9MPd5BMjuE7jrUdem2scGrA ZgVmWyVwi4UFLs88zMtM8s1Tr7kH9q+nw7gV4Gu10fpJ0FNtNGMIZL3998TiRI0siyfW Fm5UKsDRuL4P7+fdOEtk17BTRh1iEJVH73O21MD5PO3KUvSk3zrg+sb9XxUmFpITh8BY BFp+XGrit/mxlddWS1JfT00cP8vKrHBN3mjcJTzdu0Sw/y9JoJlYOyL5ZHcbskY47Uoe OrKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hB7srH0p; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f89-v6si13920201pff.208.2018.06.01.16.00.34; Fri, 01 Jun 2018 16:00:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hB7srH0p; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750927AbeFAXAd (ORCPT + 13 others); Fri, 1 Jun 2018 19:00:33 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:55241 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750758AbeFAXAc (ORCPT ); Fri, 1 Jun 2018 19:00:32 -0400 Received: by mail-wm0-f66.google.com with SMTP id o13-v6so5576082wmf.4 for ; Fri, 01 Jun 2018 16:00:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=IdfSceJ2k5e8GqDUG+uLK1tN1pssZ20mCW71Dtf6uaw=; b=hB7srH0puUPmQR9Pxdaf26j7Qk54keawtx/GGf5WVTjuZs5suDSHlv3vHK6Q9hsDFB dDTjVol7xrYcf7c7ZzkKV8l4xCchIOqNfHuZBrVpzUJLka7h+FQulGQ1CIyvD46eSYoJ xJez9B1ngSj4F5RCVsGyi4L8W+izMiXculvLY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=IdfSceJ2k5e8GqDUG+uLK1tN1pssZ20mCW71Dtf6uaw=; b=RN1YHZzCUtc4GyBW1tmRMK1357nRjmOtfxm6CFtyAHZrJWwzXhC7UE2Qp48NQt6823 br4UEJQelesPH2t4Q08cM1BAOW/o/Hr+8hElGLy+x8h+Hxw2ZLGJZ+GM60/ywrdzlrI3 KkBvYK+eMSAdMfAalnVZHBGUuhjg1D+FXQ/rYZ7kG7JN3OsbW1hrOLvjE9bQXfCMTxzN 48+oNVOADbE+7KJSGBQ4ZCSbG8S0VSvfkDEr5+X+/8HW87v4sg77J5iGijca+oR1b6A0 8BdpP0gx7JsPVMqVqJmWjSt7fc9UF4BkebClxpBzRP1oojDH7fRfQedFNcMhHPZ9ftnk 02aA== X-Gm-Message-State: ALKqPwfDHfSF16NmQmaphNy1R9+MWtyNc1e4YgCTHWf9kL76MF+TIYAv EEyKNSkZryLdGsMVQq/bbfuj8w== X-Received: by 2002:a1c:e8c6:: with SMTP id f67-v6mr3555267wmi.25.1527894030695; Fri, 01 Jun 2018 16:00:30 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id e63-v6sm347995wma.46.2018.06.01.16.00.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Jun 2018 16:00:30 -0700 (PDT) From: Srinivas Kandagatla To: robh+dt@kernel.org, frowand.list@gmail.com Cc: linux-arm-msm@vger.kernel.org, bgoswami@codeaurora.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rohkumar@qti.qualcomm.com, Srinivas Kandagatla Subject: [PATCH] of: platform: stop accessing invalid dev in of_platform_device_destroy Date: Fri, 1 Jun 2018 23:58:22 +0100 Message-Id: <20180601225822.23439-1-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Immediately after the platform_device_unregister() the device will be cleaned up. Accessing the freed pointer immediately after that will crash the system. Found this bug when kernel is built with CONFIG_PAGE_POISONING and testing loading/unloading audio drivers in a loop on Qcom platforms. Fix this by removing accessing the dev pointer. Below is the carsh trace: Unable to handle kernel paging request at virtual address 6b6b6b6b6b6c03 Mem abort info: ESR = 0x96000021 Exception class = DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 Data abort info: ISV = 0, ISS = 0x00000021 CM = 0, WnR = 0 [006b6b6b6b6b6c03] address between user and kernel address ranges Internal error: Oops: 96000021 [#1] PREEMPT SMP Modules linked in: CPU: 2 PID: 1784 Comm: sh Tainted: G W 4.17.0-rc7-02230-ge3a63a7ef641-dirty #204 Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) pstate: 80000005 (Nzcv daif -PAN -UAO) pc : clear_bit+0x18/0x2c lr : of_platform_device_destroy+0x64/0xb8 sp : ffff00000c9c3930 x29: ffff00000c9c3930 x28: ffff80003d39b200 x27: ffff000008bb1000 x26: 0000000000000040 x25: 0000000000000124 x24: ffff80003a9a3080 x23: 0000000000000060 x22: ffff00000939f518 x21: ffff80003aa79e98 x20: ffff80003aa3dae0 x19: ffff80003aa3c890 x18: ffff800009feb794 x17: 0000000000000000 x16: 0000000000000000 x15: ffff800009feb790 x14: 0000000000000000 x13: ffff80003a058778 x12: ffff80003a058728 x11: ffff80003a058750 x10: 0000000000000000 x9 : 0000000000000006 x8 : ffff80003a825988 x7 : bbbbbbbbbbbbbbbb x6 : 0000000000000001 x5 : 0000000000000000 x4 : 0000000000000001 x3 : 0000000000000008 x2 : 0000000000000001 x1 : 6b6b6b6b6b6b6c03 x0 : 0000000000000000 Process sh (pid: 1784, stack limit = 0x (ptrval)) Call trace: clear_bit+0x18/0x2c q6afe_remove+0x20/0x38 apr_device_remove+0x30/0x70 device_release_driver_internal+0x170/0x208 device_release_driver+0x14/0x20 bus_remove_device+0xcc/0x150 device_del+0x10c/0x310 device_unregister+0x1c/0x70 apr_remove_device+0xc/0x18 device_for_each_child+0x50/0x80 apr_remove+0x18/0x20 rpmsg_dev_remove+0x38/0x68 device_release_driver_internal+0x170/0x208 device_release_driver+0x14/0x20 bus_remove_device+0xcc/0x150 device_del+0x10c/0x310 device_unregister+0x1c/0x70 qcom_smd_remove_device+0xc/0x18 device_for_each_child+0x50/0x80 qcom_smd_unregister_edge+0x3c/0x70 smd_subdev_remove+0x18/0x28 rproc_stop+0x48/0xd8 rproc_shutdown+0x60/0xe8 state_store+0xbc/0xf8 dev_attr_store+0x18/0x28 sysfs_kf_write+0x3c/0x50 kernfs_fop_write+0x118/0x1e0 __vfs_write+0x18/0x110 vfs_write+0xa4/0x1a8 ksys_write+0x48/0xb0 sys_write+0xc/0x18 el0_svc_naked+0x30/0x34 Code: d2800022 8b400c21 f9800031 9ac32043 (c85f7c22) ---[ end trace 32020935775616a2 ]--- Signed-off-by: Srinivas Kandagatla --- drivers/of/platform.c | 2 -- 1 file changed, 2 deletions(-) -- 2.16.2 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/of/platform.c b/drivers/of/platform.c index c00d81dfac0b..78c32b93c0e7 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -544,8 +544,6 @@ int of_platform_device_destroy(struct device *dev, void *data) amba_device_unregister(to_amba_device(dev)); #endif - of_node_clear_flag(dev->of_node, OF_POPULATED); - of_node_clear_flag(dev->of_node, OF_POPULATED_BUS); return 0; } EXPORT_SYMBOL_GPL(of_platform_device_destroy);