Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751031AbbGMMYP (ORCPT ); Mon, 13 Jul 2015 08:24:15 -0400 Received: from mail-oi0-f41.google.com ([209.85.218.41]:34084 "EHLO mail-oi0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751019AbbGMMYN (ORCPT ); Mon, 13 Jul 2015 08:24:13 -0400 MIME-Version: 1.0 In-Reply-To: <1434589243-502-2-git-send-email-gregory.0xf0@gmail.com> References: <1434589243-502-1-git-send-email-gregory.0xf0@gmail.com> <1434589243-502-2-git-send-email-gregory.0xf0@gmail.com> Date: Mon, 13 Jul 2015 14:24:12 +0200 Message-ID: Subject: Re: [PATCH v3 1/4] gpio: brcmstb: fix null ptr dereference in driver remove From: Linus Walleij To: Gregory Fong Cc: "linux-gpio@vger.kernel.org" , Alexandre Courbot , bcm-kernel-feedback-list , Brian Norris , "devicetree@vger.kernel.org" , Florian Fainelli , Ian Campbell , Kumar Gala , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Mark Rutland , Pawel Moll , Rob Herring , Russell King Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 988 Lines: 25 On Thu, Jun 18, 2015 at 3:00 AM, Gregory Fong wrote: > If a failure occurs during probe, brcmstb_gpio_remove() is called. In > remove, we call platform_get_drvdata(), but at the time of failure in > the probe the driver data hadn't yet been set which leads to a NULL > ptr dereference in the remove's list_for_each. Call > platform_set_drvdata() and set up list head right after allocating the > priv struct to both avoid the null pointer dereference that could > occur today. To guard against potential future changes, check for > null pointer in remove. > > Reported-by: Tim Ross > Signed-off-by: Gregory Fong > --- > New in v3. Patch applied. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/