Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751155AbdGGEvz (ORCPT ); Fri, 7 Jul 2017 00:51:55 -0400 Received: from gateway24.websitewelcome.com ([192.185.51.228]:48688 "EHLO gateway24.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750811AbdGGEvy (ORCPT ); Fri, 7 Jul 2017 00:51:54 -0400 Date: Thu, 06 Jul 2017 23:51:51 -0500 Message-ID: <20170706235151.Horde.0bV02ctiQ59WNlX28lLjSHX@gator4166.hostgator.com> From: "Gustavo A. R. Silva" To: Peter Rosin Cc: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: multiplexer: add NULL check on devm_kzalloc() return value References: <20170706220851.GA26284@embeddedgus> <01d4a23f-489a-6d1c-50ef-a77207719eae@axentia.se> <20170706233558.Horde.ODusk8GBY3IYWs1gZsRKWv4@gator4166.hostgator.com> In-Reply-To: User-Agent: Horde Application Framework 5 Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes MIME-Version: 1.0 Content-Disposition: inline X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 108.167.133.22 X-Exim-ID: 1dTLF9-0015Bf-Fq X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: gator4166.hostgator.com [108.167.133.22]:24259 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 8 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1654 Lines: 63 Quoting Peter Rosin : > On 2017-07-07 06:35, Gustavo A. R. Silva wrote: >> Hi Peter, >> >> Quoting Peter Rosin : >> >>> On 2017-07-07 00:08, Gustavo A. R. Silva wrote: >>>> Check return value from call to devm_kzalloc() >>>> in order to prevent a NULL pointer dereference. >>> >>> Right, thanks for finding that one! There's another one inside the >>> for loop that is just starting in the context of this patch. Care >>> to fix checking the return value of that devm_kmemdup as well? >>> >> >> Sure, I'll send a new patch shortly. >> >>> And someone should perhaps teach Coccinelle about devm_kmemdup... >>> >> >> Good catch, I just implemented that script. >> >>>> This issue was detected using Coccinelle and the following semantic patch: >>>> >>>> @@ >>>> expression x; >>>> identifier fld; >>>> @@ >>>> >>>> * x = devm_kzalloc(...); >>>> ... when != x == NULL >>>> x->fld >>>> >>>> >>> >>> One of these blank lines should perhaps be a "Fixes:" tag? >>> >> >> mmm, I don't get this... > > If you add a Fixes-tag, like below, you help the stable kernel maintainers > decide what to look at. In this case it might be overkill since the thing > you fix is so fresh and does not apply to any old kernel. But I think it > is a good habit... > > Fixes: 7ba9df54b091 ("iio: multiplexer: new iio category and iio-mux driver") > > (and it is a bit unusual to see two blank lines before the SoB-tag) > > Sorry for not spelling it out the first time. > Oh, I get it now. Thank you very much for clarifying. I will definitely keep that in mind for future fixes when that could apply. Thanks! -- Gustavo A. R. Silva