Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753642AbcDNJcF (ORCPT ); Thu, 14 Apr 2016 05:32:05 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:43264 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752599AbcDNJcC (ORCPT ); Thu, 14 Apr 2016 05:32:02 -0400 Date: Thu, 14 Apr 2016 12:31:49 +0300 From: Dan Carpenter To: Shaohua Li Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch v2] md/raid0: fix uninitialized variable bug Message-ID: <20160414093149.GA16549@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160413170240.GB6186@kernel.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 734 Lines: 20 If this function fails the callers expect that *private_conf is set to an ERR_PTR() but that isn't true for the first error path where we can't allocate "conf". It leads to some uninitialized variable bugs. Signed-off-by: Dan Carpenter --- v2: Shaohua suggested a different fix diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 2ea12c6..f63dbb6 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -85,6 +85,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf) struct r0conf *conf = kzalloc(sizeof(*conf), GFP_KERNEL); unsigned short blksize = 512; + *private_conf = ERR_PTR(-ENOMEM); if (!conf) return -ENOMEM; rdev_for_each(rdev1, mddev) {