Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp118592pxv; Wed, 30 Jun 2021 01:13:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwrK4OuS8GIhbEjpC6zSNrJpyNee/H6/xXnyLgKAY0nsvwnYN1esZudmgRIDb1IemOol7r X-Received: by 2002:aa7:dc02:: with SMTP id b2mr13066163edu.46.1625040809797; Wed, 30 Jun 2021 01:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625040809; cv=none; d=google.com; s=arc-20160816; b=YZJ3InpZXgd+HOCdZoMFeDQPACySgAwqavGmoP3B1nQSW3b6Ubn/e8sQNl+WRnl85N 5EmaSO7V23a4TX2aFmuNWfnJUFNItyOLZEPHqV1c04L6VcNkjpyO6ZmOC3pn9Yjh5kR6 z1y6EtD9vFAF3c8d22s8obHX/dSFfMceyiq+VG5cozdEa+tdenVmdF6vXCNSZLhmx1Ad gBFS1R7EZAZeZZ2dLEcxYbzu6fbm2PS6XPFZM5U8aq2ANQEqdgwD/R2OdyLLFbPBqTRy jYRX4dYS4sVnLSisr0l/6ou/6zAOysll+ciGxfiYL+BoQKZ58ZuY78D0c8pw+oa8eiRf pYAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:message-id:date:thread-index :thread-topic:subject:to:from; bh=xAKRHwk2Xmz7EE9KqXLWG2v6DlO4MZtVE9CvrVE7Yh0=; b=K4DqJ8NemNzRwvCmSMzio5BQcwMYWbjqzp3ihtXC8kN7Ba5laFcOf0TfEKBhk39Uoj G+bgyFxFAvh25fcULHrGNwnUGuH8JaF9cJUrl/Pe66GMkbhQBFElawXXy1wApB7N4G9N dgab6cVlopEpYL56WoXCqsNQjjjtDyIxoykQpAFddoArLgYOK5XB5REkbbyDfG3FiT4Y kN0JdvgK0MrJ/WTHnBwtY4PT2gjBQnRaHb8BUJoQxcvUnghnYRJ5qEFlFxGe+EZ5TuNl yCNNVZhBz/y3DjIDu4xyW3NorygAB/xiJwsX4h2ELMEw315otGzL3qdFiCQ0TMxbPNbE Yufg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hyperstone.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v4si18779304ejv.698.2021.06.30.01.13.05; Wed, 30 Jun 2021 01:13:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hyperstone.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233223AbhF3IMM convert rfc822-to-8bit (ORCPT + 99 others); Wed, 30 Jun 2021 04:12:12 -0400 Received: from de-smtp-delivery-105.mimecast.com ([194.104.111.105]:21265 "EHLO de-smtp-delivery-105.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232954AbhF3IML (ORCPT ); Wed, 30 Jun 2021 04:12:11 -0400 Received: from GBR01-CWL-obe.outbound.protection.outlook.com (mail-cwlgbr01lp2058.outbound.protection.outlook.com [104.47.20.58]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-12-Dc0_KYCqOtCL84aVUVYo6g-1; Wed, 30 Jun 2021 10:09:40 +0200 X-MC-Unique: Dc0_KYCqOtCL84aVUVYo6g-1 Received: from CWXP265MB2680.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:89::10) by CWLP265MB2580.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:a7::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Wed, 30 Jun 2021 08:09:39 +0000 Received: from CWXP265MB2680.GBRP265.PROD.OUTLOOK.COM ([fe80::259d:65ac:ae6d:409d]) by CWXP265MB2680.GBRP265.PROD.OUTLOOK.COM ([fe80::259d:65ac:ae6d:409d%9]) with mapi id 15.20.4264.026; Wed, 30 Jun 2021 08:09:39 +0000 From: =?iso-8859-1?Q?Christian_L=F6hle?= To: "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "axboe@kernel.dk" , =?iso-8859-1?Q?Christian_L=F6hle?= Subject: [PATCH] block: prevent sending events from removed device Thread-Topic: [PATCH] block: prevent sending events from removed device Thread-Index: AQHXbYcPaY+gyAaNCEO3EseEwW+vDg== Date: Wed, 30 Jun 2021 08:09:39 +0000 Message-ID: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [185.80.168.10] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ff1c51c8-8fb8-4e12-cf00-08d93b9e68c7 x-ms-traffictypediagnostic: CWLP265MB2580: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0 x-microsoft-antispam-message-info: dc5GgzqLci+Or4h5A27tJsXx+F034tg90MvyaZLDRzjIfsYcs+M/Ooesb4xwEVKU6ZtzZIXeSKkZUoCvEp59AmyY2yDDCnYid2/DPd4TYipAr/DDWsDzi1aZCLMdMoIjt3ijtoA5exXRBphAg2t9jAlIO5pAi0GAyw/hq2ywWaSc/D7AZruQWT0pbOnZvuuOZwrqLRyPo0JNabfpOTB++sRcR+q8TDvVTVs8NveWMhsORk9pptYyBigaq2WAR8dBIFZw659QR/rqTmt2eLnr3esFvNWR8AUrN8AoDSQ7C3Pd85jMubNGix/xrv99WcpoQ1zaJ5EqzroWwJQTEkoiG+v+Gt+EJ24PN7EWnPpCZEfeZEIz39OjiczMAmCIyueZ4Z/vSKi1cxRxsAbI6SkfzRl8828DAwab8Uj6OVJ8WMCPZjWsM8W6ywcbDzLV6e+z1tuvS7WYx/pulpR/rcZiUJUoHYEP1aClBE6raRxDYehGb2/KZ67/nkqHfjwE1mg4gjokWfbqIwnCsqzLXf5KV5RjS2FfqDVWD8X+d3GyuxUoikox2GcK98CXrIY0OZRdqJS8s1Np5kqAVo1kDGQQFgUcw2Je8YMl4kzpOu7pPVsBR9OCe+U6XBUV6Hr7URxHtiZglBSz1F3ciax4G9zfrg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWXP265MB2680.GBRP265.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(376002)(366004)(39840400004)(136003)(396003)(346002)(2906002)(52536014)(110136005)(8936002)(83380400001)(8676002)(316002)(64756008)(66476007)(91956017)(66946007)(76116006)(66556008)(66446008)(71200400001)(86362001)(6506007)(26005)(5660300002)(4744005)(33656002)(55016002)(9686003)(186003)(478600001)(38100700002)(7696005)(122000001);DIR:OUT;SFP:1101 x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?2CJvUtTdhsz5AI7VMbEmn+HgU4ma90M921B/1K1wWFPbIiy8QS+GEOtQig?= =?iso-8859-1?Q?S2fCov/24tJwm64QLVsyjWxpDAAKmzHkVt44nY+QAqp3K9M9GacybJygHB?= =?iso-8859-1?Q?AeDe1kASdTKiGYl1X32xkTwfObxu+MwZOkpgwq+2f3hXnVOCdobXNI04B5?= =?iso-8859-1?Q?G0y1kZrfMaxJS/Kb5pZn5J6PRMlqE6+m+DJFax4apj5vRLzBW6ba+HhxIm?= =?iso-8859-1?Q?qDPwtIlqDjcW7OUfTegIcW7LsaeM20wTmtQO9eRgQTncuOEl6R5DX11zNi?= =?iso-8859-1?Q?l8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VRs5xFW7rSYbG0LUYrluMxmQwaWO+f?= =?iso-8859-1?Q?Keb+rwVv3dQgj706zlvYbUZq1SecVBETvy0EjaqWkdzo7ttFq7CnQ8kxFP?= =?iso-8859-1?Q?VkMVc9vBI8d1Kd6RZr8ixFUILPrGiqwWA3NnAnkJ0WdDWzUGOqhw0+xQvQ?= =?iso-8859-1?Q?zkfiW77DZvdjPPK/m55k/FmO4elEKyXCgusv745oq5OLGP4=3D?= MIME-Version: 1.0 X-OriginatorOrg: hyperstone.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CWXP265MB2680.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: ff1c51c8-8fb8-4e12-cf00-08d93b9e68c7 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jun 2021 08:09:39.7317 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 86f203eb-e878-4188-b297-34c118c18b11 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 0vHi4OWiuLcZHP4bvmIuaxBzblSMFXbAEck3GmdfcAa19jZTqFDNakJ531nOXnwm4uH2GHd4fsfSB8COgmlpLA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWLP265MB2580 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: hyperstone.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Skip kobject_uevent_env in case the associated kobject no longer exists, as calling kobject_uevent_env with NULL is not safe. Signed-off-by: Christian Loehle --- block/genhd.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index 9f8cb7beaad1..46629fbe23ae 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1655,8 +1655,16 @@ static void disk_check_events(struct disk_events *ev, (disk->event_flags & DISK_EVENT_FLAG_UEVENT)) envp[nr_events++] = disk_uevents[i]; - if (nr_events) - kobject_uevent_env(&disk_to_dev(disk)->kobj, KOBJ_CHANGE, envp); + if (nr_events) { + struct kobject *dev_kobj = kobject_get(&disk_to_dev(disk)->kobj); + /* The device kobject might have been removed in the + * meantime, so check for it first. + * If it was removed there is no need to signal events + */ + if (!dev_kobj) + kobject_uevent_env(dev_kobj, KOBJ_CHANGE, envp); + kobject_put(dev_kobj); + } } /* -- 2.32.0 Hyperstone GmbH | Line-Eid-Strasse 3 | 78467 Konstanz Managing Directors: Dr. Jan Peter Berns. Commercial register of local courts: Freiburg HRB381782