From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, T_DKIMWL_WL_HIGH,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7AF4C04AAA for ; Mon, 6 May 2019 08:34:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8A97208C0 for ; Mon, 6 May 2019 08:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557131691; bh=jFwc2BDkRhYUSCCt361d4c7fwgUAreClV7jhe5+bBiA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=ZZlrBeY0qpaD1s5yxSOkt1iW3wwB/tLciWRMCZOsnuDMr3d/7kggVfvVcEWhRbZCY XuuEVaB1pLtO3hXwqKIPVRW1ccWRnH79TCuWk0uLyLJHTkAMOU4T2/l/p6Nf6KGpRU bBEmHIJahptRRG8R4hPZaqdEvqUmSDoJ/4q+Itfo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725894AbfEFIev (ORCPT ); Mon, 6 May 2019 04:34:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:54814 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725837AbfEFIev (ORCPT ); Mon, 6 May 2019 04:34:51 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B23462082F; Mon, 6 May 2019 08:34:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557131690; bh=jFwc2BDkRhYUSCCt361d4c7fwgUAreClV7jhe5+bBiA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OwD10NAs/F9s/T1LyhV5B9KtQYKyoNNkoVKVE8JEgGbXImAUW4D4w9dBoM7V7Rljc N7qo3jQeqHtSoIEiyoMQW3j+CPzjMHKbaZwexTCa3Sy5vcjiNaSHkxyzfXL7WCiB93 FsvOjOyuuR6Ekl+BnvTcEE24djQ1X+OaMnVC5LmQ= Date: Mon, 6 May 2019 10:34:47 +0200 From: Greg Kroah-Hartman To: Geert Uytterhoeven Cc: Linux Kernel Mailing List , stable , Kangjie Lu , Jacek Anaszewski , "Sasha Levin (Microsoft)" Subject: Re: [PATCH 5.0 100/101] leds: pca9532: fix a potential NULL pointer dereference Message-ID: <20190506083447.GA1198@kroah.com> References: <20190502143339.434882399@linuxfoundation.org> <20190502143346.636141727@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Mon, May 06, 2019 at 10:21:28AM +0200, Geert Uytterhoeven wrote: > Hi Greg, > > On Thu, May 2, 2019 at 5:34 PM Greg Kroah-Hartman > wrote: > > [ Upstream commit 0aab8e4df4702b31314a27ec4b0631dfad0fae0a ] > > > > In case of_match_device cannot find a match, return -EINVAL to avoid > > NULL pointer dereference. > > > > Fixes: fa4191a609f2 ("leds: pca9532: Add device tree support") > > Signed-off-by: Kangjie Lu > > Signed-off-by: Jacek Anaszewski > > Signed-off-by: Sasha Levin (Microsoft) > > > --- a/drivers/leds/leds-pca9532.c > > +++ b/drivers/leds/leds-pca9532.c > > @@ -513,6 +513,7 @@ static int pca9532_probe(struct i2c_client *client, > > const struct i2c_device_id *id) > > { > > int devid; > > + const struct of_device_id *of_id; > > struct pca9532_data *data = i2c_get_clientdata(client); > > struct pca9532_platform_data *pca9532_pdata = > > dev_get_platdata(&client->dev); > > @@ -528,8 +529,11 @@ static int pca9532_probe(struct i2c_client *client, > > dev_err(&client->dev, "no platform data\n"); > > return -EINVAL; > > } > > - devid = (int)(uintptr_t)of_match_device( > > - of_pca9532_leds_match, &client->dev)->data; > > + of_id = of_match_device(of_pca9532_leds_match, > > + &client->dev); > > + if (unlikely(!of_id)) > > This condition (1) can never be true, as of_pca9532_leds_match[] > populates the .data field of all entries, and (2) is already checked for > in pca9532_of_populate_pdata(), so pca9532_probe() would already > have aborted with -ENODEV before. > > https://lore.kernel.org/lkml/CAMuHMdXELu2tcSB5C1yKUGft6sDGPAy997ApPzy17n0MssfyWA@mail.gmail.com/ > > So please stop backporting this to even more stable trees. > Thanks! It's already merged in a bunch of stable trees, so let's just leave it as-is :) thanks, greg k-h