From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753941AbcG0IKQ (ORCPT ); Wed, 27 Jul 2016 04:10:16 -0400 Received: from mail.aswsp.com ([193.34.35.150]:17613 "EHLO mail.aswsp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753937AbcG0IJD (ORCPT ); Wed, 27 Jul 2016 04:09:03 -0400 Message-ID: <57986CF3.4070602@parrot.com> Date: Wed, 27 Jul 2016 10:12:35 +0200 From: Gregor Boirie User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 MIME-Version: 1.0 To: Alison Schofield , CC: , , , , Subject: Re: [PATCH] tools: iio: iio_generic_buffer: initialize channel array pointer References: <20160727031734.GA31933@d830.WORKGROUP> In-Reply-To: <20160727031734.GA31933@d830.WORKGROUP> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [46.218.109.88] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/27/2016 05:17 AM, Alison Schofield wrote: > Uninitialized channel pointer causes segmentation fault when we > call free(channel) during cleanup() with no channels initialized. > This happens when you exit early for usage errors. Initialize > the pointer to NULL when it is declared. > > Signed-off-by: Alison Schofield > Cc: Daniel Baluta > --- > tools/iio/iio_generic_buffer.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c > index 0e8a1f7..ae68bf0 100644 > --- a/tools/iio/iio_generic_buffer.c > +++ b/tools/iio/iio_generic_buffer.c > @@ -348,7 +348,7 @@ int main(int argc, char **argv) > int notrigger = 0; > char *dummy; > > - struct iio_channel_info *channels; > + struct iio_channel_info *channels = NULL; > > register_cleanup(); > Tested-by: Gregor Boirie greg.