From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933832AbcIUMKm (ORCPT ); Wed, 21 Sep 2016 08:10:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59348 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933064AbcIUMKl (ORCPT ); Wed, 21 Sep 2016 08:10:41 -0400 Date: Wed, 21 Sep 2016 17:40:38 +0530 From: Amit Shah To: SF Markus Elfring Cc: virtualization@lists.linux-foundation.org, Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Rusty Russell , LKML , kernel-janitors@vger.kernel.org, Julia Lawall Subject: Re: [PATCH 02/11] virtio_console: Less function calls in init_vqs() after error detection Message-ID: <20160921121038.GE1375@amit-lp.rh> References: <566ABCD9.1060404@users.sourceforge.net> <020438b9-a7f8-0050-04c1-43382ba60b75@users.sourceforge.net> <490b98e1-6129-f11f-55ff-94219ebce6d6@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <490b98e1-6129-f11f-55ff-94219ebce6d6@users.sourceforge.net> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 21 Sep 2016 12:10:40 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On (Wed) 14 Sep 2016 [16:01:28], SF Markus Elfring wrote: > From: Markus Elfring > Date: Wed, 14 Sep 2016 14:00:35 +0200 > > The kfree() function was called in up to five cases > by the init_vqs() function during error handling even if > the passed variable contained a null pointer. > > * Return directly after a call of the function "kmalloc_array" failed > at the beginning. > > * Split a condition check for memory allocation failures so that > each pointer from these function calls will be checked immediately. > > See also background information: > Topic "CWE-754: Improper check for unusual or exceptional conditions" > Link: https://cwe.mitre.org/data/definitions/754.html > > * Adjust jump targets according to the Linux coding style convention. So I've seen this series and I'm not yet sure how I feel about the patches - f.e. in this one, it adds more lines than it removes to achieve the same effect. I think the code is currently more readable than after these changes. And even if kfree is called multiple times, it isn't a huge bother -- it's error case anyway, very unlikely to trigger, but keeps everything very readble. Amit