From patchwork Tue Jun 5 07:13:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 925325 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 410NMr1cqKz9s1B for ; Tue, 5 Jun 2018 17:14:16 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SE424EL5"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 410NMq59gDzF1g0 for ; Tue, 5 Jun 2018 17:14:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SE424EL5"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c01::244; helo=mail-pl0-x244.google.com; envelope-from=joel.stan@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SE424EL5"; dkim-atps=neutral Received: from mail-pl0-x244.google.com (mail-pl0-x244.google.com [IPv6:2607:f8b0:400e:c01::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 410NMT3yZkzF1mw for ; Tue, 5 Jun 2018 17:13:57 +1000 (AEST) Received: by mail-pl0-x244.google.com with SMTP id c23-v6so956016plz.12 for ; Tue, 05 Jun 2018 00:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=52ATi/osT8Kw6qNYY5vv+95BHSlFlChvzggt8UDioD4=; b=SE424EL5+0slhUb6Iz0Woqfvl16wU1ef9BLJW0IbAgA2nxmpcuW5fCWBlqsdg5yLm9 NkuH5kJW8apLSYvo4kcY7zWuQ8ZfbJ6c9L2Y3tkSdTzxqCRRBjjjXZdSpikncVsbOENv WCIOHk9oGHEAIQHOfdvoQG8tn8kr1I5n2HrUP1+OI625HoR2cmNwGK5abCAx2+aijlCM wd00Fqls2zee7KxTTg1p/I0V93a6bxgDym7uaW0oNmx9cN/nLB1jPLkJfteGiCOzMrFs UR14BPiS0VRUMN2HJQN1sEec/97pkBy3OlXxWE4qJoZmSeGqWJlFc1ToLst4uad4ZjEc TRLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=52ATi/osT8Kw6qNYY5vv+95BHSlFlChvzggt8UDioD4=; b=Fz29CiX5Z25/E8J2QPQ1gTXt0CMNn6CmoNDQBeVe1Pa/dnYlsV4mWoUHqZCDuhWEyD Cnyik4s1AQwZ3oTO9oHhPwjTeghQ9fBAf7FawX0zeFDmJbvOJbyJJjfA11b0/5sZGgef s61S3NPcP0TdOsayJrHaVa48IRq7s+856FBpirT5yvLAHM8WTEyqmw9G4rDqZebw1S9N zTe1CWz6sL9G5bYxZrMteyzteRsHPvdAcl9S9XhFPgE13/nOlOX75r6En4IczH8Rq/sa zZ7wJhLQ/8wabgmCvsQP9CqRl6XTYXdBIr1mkJXJXPfwW27nb5f6ErS2DLnl1fElWJE8 9Yhg== X-Gm-Message-State: ALKqPwfSIMmbT1esYH1HVlLkoZiu3yIhCZq3joNXdmdXvG87S9RUOayW zo0gClNXR+JyvkwWIqB1kJPVd4UO X-Google-Smtp-Source: ADUXVKLa/y5Z2i/qNo6XvMIpclzhmzLGp/HffbEkMOa7TD5lEU9QUrgxx5hxhADVk/XUsW+TObIQWQ== X-Received: by 2002:a17:902:7688:: with SMTP id m8-v6mr22337078pll.54.1528182835151; Tue, 05 Jun 2018 00:13:55 -0700 (PDT) Received: from aurora.jms.id.au ([203.0.153.9]) by smtp.gmail.com with ESMTPSA id y8-v6sm39201026pgq.75.2018.06.05.00.13.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jun 2018 00:13:54 -0700 (PDT) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Tue, 05 Jun 2018 16:43:48 +0930 From: Joel Stanley To: skiboot@lists.ozlabs.org Date: Tue, 5 Jun 2018 16:43:34 +0930 Message-Id: <20180605071337.22915-2-joel@jms.id.au> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180605071337.22915-1-joel@jms.id.au> References: <20180605071337.22915-1-joel@jms.id.au> Subject: [Skiboot] [PATCH 1/4] occ-sensor: Avoid using uninitialised struct cpu_thread X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" When adding the sensors in occ_sensors_init, if the type is not OCC_SENSOR_LOC_CORE, then the loop to find 'c' will not be executed. Then c->pir is used for both of the the add_sensor_node calls below. This provides a default value of 0 instead. Found using scan-build. Signed-off-by: Joel Stanley Reviewed-by: Shilpasri G Bhat --- It may not be the correct fix. Please review closely. --- hw/occ-sensor.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/occ-sensor.c b/hw/occ-sensor.c index a31a2a5d6dea..783f75740c42 100644 --- a/hw/occ-sensor.c +++ b/hw/occ-sensor.c @@ -543,6 +543,7 @@ bool occ_sensors_init(void) for (i = 0; i < hb->nr_sensors; i++) { const char *type, *loc; struct cpu_thread *c = NULL; + uint32_t pir = 0; if (md[i].structure_type != OCC_SENSOR_READING_FULL) continue; @@ -565,6 +566,7 @@ bool occ_sensors_init(void) break; if (!c) continue; + pir = c->pir; } type = get_sensor_type_string(md[i].type); @@ -572,7 +574,7 @@ bool occ_sensors_init(void) add_sensor_node(loc, type, i, SENSOR_SAMPLE, &md[i], &phandles[phcount], &ptype[phcount], - c->pir, occ_num, chip->id); + pir, occ_num, chip->id); phcount++; /* Add energy sensors */ @@ -581,7 +583,7 @@ bool occ_sensors_init(void) add_sensor_node(loc, "energy", i, SENSOR_ACCUMULATOR, &md[i], &phandles[phcount], &ptype[phcount], - c->pir, occ_num, chip->id); + pir, occ_num, chip->id); phcount++; }