Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1163074pxu; Fri, 27 Nov 2020 00:55:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPpMUCV/uUsP6crQlRhfQBHvZ9O5CDVxpAyCgI1Ubt5b11+BYBOmiYlX/j3q2POi2AMfnO X-Received: by 2002:a05:6402:31a5:: with SMTP id dj5mr6402892edb.110.1606467332897; Fri, 27 Nov 2020 00:55:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606467332; cv=none; d=google.com; s=arc-20160816; b=JabueTKbFr+IkI7Ef7RlpowPtOfOcZEfUYoMhgc5wZWeLrmpYyvVIAUCbGcPJtmvyH YzRt8a2Fg6hoVZGWKKrXk0UrDf9drNoo4tIgCHy91xAFZEbad9qXD4JkRn9EqoPc7t42 OMMfu2w6HInXzp1MW7RBEb2fxwHND+YkjrBNgUEOGvBdMozLWRxZ27266oivmsXGAFJl NRUJpMn5A9kmqLhXOQcCc9KayA/8MYVfIdNBJGOK7Y4/FEEO2bLYOtrgXdUqyu88ZyGx C+e4mvgcYC1vShAWVmXCaWPyiVx1rRXs5RjsQ9sKyI0QDpiEhC74RsQTWSvwLE97o8dr I6Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=TMF6HFV6zYLpKv2x82xJJ+LMyxzoElrTn5N5417TLXw=; b=Zm1sp1YUSgiCDy64UyCNCzA0DBUzosVfW27eBu+dYl+8cm1O40ldcyakk4MZYBEXz9 ch6MoqLiDK91xNigSt+D9kCRn5ZuJtaSOhLcYiK2yy95xzuqEeCH/QJN6TG0k63ThXyG bfZ4jGZKbVd0NeFiGPyPrMqDREFDL0KQEHy5n06U670Q9icGUvQTE1XX9wOgURbUJHre iKgfebIOdVQiqPlGQOebePnQl/k45iTB2dfatEQLmqUI8XY59m2z+bwhzZSAyDY1kk62 HUjdLic9mxKI1e/Jt2YUwFY9ZsHhv+GjlbJ0Jpvp1n9uhHCIX5VQyPPl3/waQhA+QHgA J8fQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e17si4824082edq.469.2020.11.27.00.55.10; Fri, 27 Nov 2020 00:55:32 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727301AbgK0Itw (ORCPT + 99 others); Fri, 27 Nov 2020 03:49:52 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:8045 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725865AbgK0Itw (ORCPT ); Fri, 27 Nov 2020 03:49:52 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Cj7bW5BKRzhXwL; Fri, 27 Nov 2020 16:49:27 +0800 (CST) Received: from huawei.com (10.69.192.56) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Fri, 27 Nov 2020 16:49:42 +0800 From: Luo Jiaxing To: , , CC: , , , , Subject: [PATCH v2] gpio: dwapb: fix NULL pointer dereference at dwapb_gpio_suspend() Date: Fri, 27 Nov 2020 16:50:02 +0800 Message-ID: <1606467002-62964-1-git-send-email-luojiaxing@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Following Calltrace is found when running echo freeze > /sys/power/state. [ 272.755506] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010 [ 272.755585] Call trace: [ 272.755587] dwapb_gpio_suspend+0x18/0x318 [ 272.755588] pm_generic_suspend+0x2c/0x48 [ 272.755595] acpi_subsys_suspend+0x60/0x70 [ 272.755599] dpm_run_callback.isra.18+0x40/0xe0 [ 272.755601] __device_suspend+0xf4/0x360 The reason is platform_set_drvdata() is deleted, and dwapb_gpio_suspend() get *gpio by dev_get_drvdata(). Fixes: feeaefd378ca ("gpio: dwapb: Use resource managed GPIO-chip add data method") Signed-off-by: Luo Jiaxing Acked-by: Serge Semin Reviewed-by: Andy Shevchenko --- v1->v2: 1. reduce calltrace log 2. delete blank line in tag block --- --- drivers/gpio/gpio-dwapb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index 2a9046c..4275c18 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c @@ -724,6 +724,8 @@ static int dwapb_gpio_probe(struct platform_device *pdev) return err; } + platform_set_drvdata(pdev, gpio); + return 0; } -- 2.7.4