Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6499iob; Tue, 17 May 2022 16:54:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMNGiwK4u+vZPY0Cxcb5dUFVesqN2O+3MDDyaffDFGxWKRs7o3dPsdoOCz4WIBE0mKNGGi X-Received: by 2002:a63:db17:0:b0:3c1:dc15:7a6e with SMTP id e23-20020a63db17000000b003c1dc157a6emr21922385pgg.107.1652831681585; Tue, 17 May 2022 16:54:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652831681; cv=none; d=google.com; s=arc-20160816; b=B50kJFDFghLIDtQa+UJd/yliHzbmP/MyXJrz+3MYA0VwyftuxuBU0Z9U4ke4ilV3GT OFkjdpKSp6ZM2rEvtUzPoXKeAgyFIgllEzBLGguKcoiCwqK/NUIi8832twP7kVftXql5 5xAuFTSXor0T6jTTEJhuFIhyo+nQgNf2z+A5ZjSq0xp4hb1ZPL2SLw6A/XLXZRk2lME5 voA+abzQMacdKm4RzAkHrTeSkZkz8g5RWg+jG45s1al9rLiv73R/boBQge9IrNWXn8HO zo9BbEm1e94dCi0llMa1tC32kB2WYkZZ/jFVxXJJR9LH7vgWII/5Zt64L4rOh3r56w97 re4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Pk3Lck89mAljbP4neZKyoVhMXKcSIwY1mbKJI0A4LZw=; b=Wom6rlgBzzJyTJANBrkE+pu31WLUlsmyeqeItre7GzG6Br9AuqMauebSlJteX7X5cZ cPiykWhyqHCHaMaOL7QQpaLUhwPea8Y024n7T5lQxZPrpNrWpX40/v9mr9EW6qOa2t4a dRDLl6LjD3QBKRcGWz1UXpgOwK7TjWpdMeXbT+Lm+bRUj3M1g77FLHDtJ7muHqq2t09m rtWwqD1MKE51SZeN1UH5lOQpezsI71eX4zKA4LBoXtuOyPZ3fQdBIsXNjeFgyk53zZBg +50/qb/IT9uezs+wCh01O8vM1IdFkiunDZ6AngJLNd9Hyh8Hwp3l0YBB24kJZmtOlWrq jv0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HmpElj9X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oa12-20020a17090b1bcc00b001dc6b580943si4830631pjb.5.2022.05.17.16.54.29; Tue, 17 May 2022 16:54:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HmpElj9X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1345648AbiEPTj1 (ORCPT + 99 others); Mon, 16 May 2022 15:39:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345638AbiEPTix (ORCPT ); Mon, 16 May 2022 15:38:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F10C3EF3C; Mon, 16 May 2022 12:38:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9C957B81607; Mon, 16 May 2022 19:38:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E800C385AA; Mon, 16 May 2022 19:38:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652729916; bh=10tgVETi0/0icrHOI5cWzODW+G7sx5Wwa+9DpVGgXQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HmpElj9XCIRLsteH1iMptLvGHAjow00uLj3e0rVBkfjg7YdkvnnhdxCwBgyHs3hPe ahFXm4n8its7SzljdQCvrqdom60t3Ikrull4wLwuD3orubfVy0vYet9HF57TT4/LY9 0Gr7DhP0Rxh0eHe29JGDPFpPv8KNWT9EAIAQqEuk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Alexandra Winter , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 05/19] s390/ctcm: fix variable dereferenced before check Date: Mon, 16 May 2022 21:36:18 +0200 Message-Id: <20220516193613.657644555@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220516193613.497233635@linuxfoundation.org> References: <20220516193613.497233635@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandra Winter [ Upstream commit 2c50c6867c85afee6f2b3bcbc50fc9d0083d1343 ] Found by cppcheck and smatch. smatch complains about drivers/s390/net/ctcm_sysfs.c:43 ctcm_buffer_write() warn: variable dereferenced before check 'priv' (see line 42) Fixes: 3c09e2647b5e ("ctcm: rename READ/WRITE defines to avoid redefinitions") Reported-by: Colin Ian King Signed-off-by: Alexandra Winter Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/s390/net/ctcm_sysfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/s390/net/ctcm_sysfs.c b/drivers/s390/net/ctcm_sysfs.c index ddb0aa321339..07b7177abf26 100644 --- a/drivers/s390/net/ctcm_sysfs.c +++ b/drivers/s390/net/ctcm_sysfs.c @@ -38,11 +38,12 @@ static ssize_t ctcm_buffer_write(struct device *dev, struct ctcm_priv *priv = dev_get_drvdata(dev); int rc; - ndev = priv->channel[CTCM_READ]->netdev; - if (!(priv && priv->channel[CTCM_READ] && ndev)) { + if (!(priv && priv->channel[CTCM_READ] && + priv->channel[CTCM_READ]->netdev)) { CTCM_DBF_TEXT(SETUP, CTC_DBF_ERROR, "bfnondev"); return -ENODEV; } + ndev = priv->channel[CTCM_READ]->netdev; rc = kstrtouint(buf, 0, &bs1); if (rc) -- 2.35.1