Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp546819pxb; Thu, 15 Apr 2021 00:20:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKgV9ogPQtGV5YuE+Rv2SP7EhI4DJoM3GpQOQ3vBjy7gg8kNYz2JkuuM1FOSfV6KEzsOpZ X-Received: by 2002:a17:902:f254:b029:eb:6a57:9d11 with SMTP id j20-20020a170902f254b02900eb6a579d11mr2383644plc.81.1618471232482; Thu, 15 Apr 2021 00:20:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618471232; cv=none; d=google.com; s=arc-20160816; b=gRvpSVocSEH/Mq/NFmpKBpBntN07Vk+stasv5Z0tkfb9N8XLBC0Rl1FY7tL6uoB9cs GZQ3XDLd7IGP96DjmKDTU5kic2Vp82te2u0SrzOLcUklJCw9z8CzKYu38DX2JwKdSOao pccIbr9PNFi5YM0yOIMK6DW72JqlPK35iM+bzObH19xv8q18F2SWJiy/1zE3zQ2eQ+Ch h3GoPjway/ChQ9zVEXIUT2uQ6cZ4dSaqZytuQaye1jBXRcubiJFbZk7Ym4yQBxCb4B0Q 1tLz99sjPt6Q7Do3NllVe/UkvePjs0U8EWPhzGCSpViBOVh1uDmF1HdnmWAwpMct/zk8 6nWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vWEWl8yqaDS0iZOW/vLbQ1GakQDlZ7q5bhsNmqMmQIQ=; b=SMTjtX6ltPdMt9Mg0E81K+tS0tlBuYISor2xxYqSwtyeXLismu9I0DhNoBDq8YeKV6 J/Ge8VXZ56kcoI7so2/mrdOqpnBXgXy35wbFi+d3GmRRg3f3NgzvQe5D63DX3hRPJrr5 BMY4KM1y5rRNyWfwS722Jb4enYYTnvPoIfHZF65Xbjj3hNBS7tu0rp958fyrfTjDIGFl 7GBBQmoUwgWcFu+S0RZiaZZVpqtI2OyoLWD0dDfRqSkLJzSmBNwnIwhxSP0XyILw0CtF 3KVeGfWwBC1KqRZGFXj/pUXGXiBxn2+G9y8WJctzRZHmhrCUafQGgCMWnXNpJxHhqu78 xN1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=P4EGm6D9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w132si2414635pfd.78.2021.04.15.00.20.20; Thu, 15 Apr 2021 00:20:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=P4EGm6D9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231287AbhDOHUJ (ORCPT + 99 others); Thu, 15 Apr 2021 03:20:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:44234 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231143AbhDOHUI (ORCPT ); Thu, 15 Apr 2021 03:20:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 07B6C61103; Thu, 15 Apr 2021 07:19:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618471184; bh=6yA3ZP7QlU0O7VefE5uCcyXZQdn2vdNBzoNCgVzhAH0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=P4EGm6D9qx4YMmIfc4mX90pvDkJQaQUxvxPvT3bkLwNI8RS9qrFP1kjaEwRZi8b1u GCM3x7sirPfh7DlE/+4N9TyZcBqJGMggr4/TSkeLHQ7J1hJfDfHTBn9OFUQdJxiE18 R6YDZ8PsnZCtnJY5Npaq9Uf1Xhf66z0TNDxAdahY= Date: Thu, 15 Apr 2021 09:19:42 +0200 From: Greg Kroah-Hartman To: Oded Gabbay Cc: Arnd Bergmann , Colin King , Oded Gabbay , Ofir Bitton , kernel-janitors@vger.kernel.org, Linux Kernel Mailing List Subject: Re: [PATCH][next] habanalabs/gaudi: Fix uninitialized return code rc when read size is zero Message-ID: References: <20210412161012.1628202-1-colin.king@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 15, 2021 at 10:08:26AM +0300, Oded Gabbay wrote: > On Mon, Apr 12, 2021 at 9:41 PM Arnd Bergmann wrote: > > > > On Mon, Apr 12, 2021 at 6:11 PM Colin King wrote: > > > > > > From: Colin Ian King > > > > > > In the case where size is zero the while loop never assigns rc and the > > > return value is uninitialized. Fix this by initializing rc to zero. > > > > > > Addresses-Coverity: ("Uninitialized scalar variable") > > > Fixes: 639781dcab82 ("habanalabs/gaudi: add debugfs to DMA from the device") > > > Signed-off-by: Colin Ian King > > > --- > > > drivers/misc/habanalabs/gaudi/gaudi.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalabs/gaudi/gaudi.c > > > index 8730b691ec61..b751652f80a8 100644 > > > --- a/drivers/misc/habanalabs/gaudi/gaudi.c > > > +++ b/drivers/misc/habanalabs/gaudi/gaudi.c > > > @@ -6252,7 +6252,7 @@ static int gaudi_debugfs_read_dma(struct hl_device *hdev, u64 addr, u32 size, > > > dma_addr_t dma_addr; > > > void *kernel_addr; > > > bool is_eng_idle; > > > - int rc, dma_id; > > > + int rc = 0, dma_id; > > > > > > kernel_addr = hdev->asic_funcs->asic_dma_alloc_coherent( > > > hdev, SZ_2M, > > > > > > In general, I don't like adding initializations during the declaration as that > > tends to hide warnings for the cases where a later initialization is > > missing. In this case it looks correct though. > > > > Acked-by: Arnd Bergmann > > I don't mind taking this patch for eliminating the warning but fyi, > the caller function (hl_dma_size_write) checks that the size is not > zero. If the size is zero, we never reach this function. > > Greg, do you mind applying it directly to your -next branch ? I don't > have anything pending and I'm too lazy sending a pull request on a > single patch ;) > > Reviewed-by: Oded Gabbay I can grab it from this thread, thanks! greg k-h