From patchwork Fri Sep 13 16:04:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 2890561 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C7148BFF05 for ; Fri, 13 Sep 2013 16:08:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1D9A620219 for ; Fri, 13 Sep 2013 16:08:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B22D320218 for ; Fri, 13 Sep 2013 16:07:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B8615E7E02 for ; Fri, 13 Sep 2013 09:07:58 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ie0-f173.google.com (mail-ie0-f173.google.com [209.85.223.173]) by gabe.freedesktop.org (Postfix) with ESMTP id 3CAC5E7E9D for ; Fri, 13 Sep 2013 09:04:29 -0700 (PDT) Received: by mail-ie0-f173.google.com with SMTP id ar20so3016345iec.32 for ; Fri, 13 Sep 2013 09:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=h1AqxH8bDwoVGg9byqDGQDkqkA3BsDPHhD4WkaE1iyY=; b=TxxJNyPZplQPp2OwRtfBIw6D67sBxv1QYjerpVvI+Ap1V+9pVyjj2cmtIuL0jmr1yg sJhWGzPCR2PKknmwJfIoo0y6mqWnQA2uT27jvJ96tXofiQSCqqUGd0JfFSJp99yQpMmF Zj89+dAZ42md3JLwf31BvG8ZPYW+NxKDr16DdyhqF+J2QT6PcOC61Ev0Bgcoyqcx4S1i SAxFnKawJIKiF1jbA6O0gmLPhJO8V2kIngKfhCCPt5nRl06Vz9N+nVzoMJGzZ6DUMAVb uT+s91dpEBH6zrtdn83gqVU9Tl+wr78NoydBEw+bHBX1KvMedoVRcwMY+IkGSbT7Wqwz dHyg== MIME-Version: 1.0 X-Received: by 10.50.225.39 with SMTP id rh7mr1425910igc.10.1379088268762; Fri, 13 Sep 2013 09:04:28 -0700 (PDT) Received: by 10.42.142.195 with HTTP; Fri, 13 Sep 2013 09:04:28 -0700 (PDT) In-Reply-To: <1379075614-20491-1-git-send-email-prarit@redhat.com> References: <1379075614-20491-1-git-send-email-prarit@redhat.com> Date: Fri, 13 Sep 2013 18:04:28 +0200 Message-ID: Subject: Re: [PATCH] drm, ttm Fix uninitialized warning From: David Herrmann To: Prarit Bhargava Cc: rclark@redhat.com, "dri-devel@lists.freedesktop.org" X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi On Fri, Sep 13, 2013 at 2:33 PM, Prarit Bhargava wrote: > Fix uninitialized warning. > > drivers/gpu/drm/ttm/ttm_object.c: In function ‘ttm_base_object_lookup’: > drivers/gpu/drm/ttm/ttm_object.c:213:10: error: ‘base’ may be used uninitialized in this function [-Werror=maybe-uninitialized] > kref_put(&base->refcount, ttm_release_base); > ^ > drivers/gpu/drm/ttm/ttm_object.c:221:26: note: ‘base’ was declared here > struct ttm_base_object *base; > > Signed-off-by: Prarit Bhargava > Cc: David Airlie > Cc: rclark@redhat.com Did some research on that, another fix is: if (unlikely(ret != 0)) Looks totally stupid but also silences the warning. In fact, the warning is triggered by rcu_read_unlock(); and only if PROVE_LOCKING and DEBUG_LOCK_ALLOC are enabled. And it's related to the IP-size of the rcu_read_unlock() path. I'd actually prefer "buf = NULL;" and an extended bail-out condition: if (unlikely(ret != 0 || !buf)) but it's not my decision, so: Reviewed-by: David Herrmann Cheers David > --- > drivers/gpu/drm/ttm/ttm_object.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/ttm/ttm_object.c b/drivers/gpu/drm/ttm/ttm_object.c > index 58a5f32..a868176 100644 > --- a/drivers/gpu/drm/ttm/ttm_object.c > +++ b/drivers/gpu/drm/ttm/ttm_object.c > @@ -218,7 +218,7 @@ struct ttm_base_object *ttm_base_object_lookup(struct ttm_object_file *tfile, > uint32_t key) > { > struct ttm_object_device *tdev = tfile->tdev; > - struct ttm_base_object *base; > + struct ttm_base_object *uninitialized_var(base); > struct drm_hash_item *hash; > int ret; > > -- > 1.7.9.3 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/drivers/gpu/drm/ttm/ttm_object.c b/drivers/gpu/drm/ttm/ttm_object.c index 58a5f32..6b7f7b7 100644 --- a/drivers/gpu/drm/ttm/ttm_object.c +++ b/drivers/gpu/drm/ttm/ttm_object.c @@ -228,7 +228,10 @@ struct ttm_base_object *ttm_base_object_lookup(struct ttm_object_file *tfile, if (likely(ret == 0)) { base = drm_hash_entry(hash, struct ttm_base_object, hash); ret = kref_get_unless_zero(&base->refcount) ? 0 : -EINVAL; + } else { + ret = -EINVAL; } + rcu_read_unlock();