Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2358816ybl; Sun, 26 Jan 2020 00:34:19 -0800 (PST) X-Google-Smtp-Source: APXvYqw0KqqWwiMatJ9aPf/JjdJifg/vIBwZWe2wNQ3CBiyxqfPmgPaXIfljttKSjM0zAW52WzUR X-Received: by 2002:aca:c256:: with SMTP id s83mr4432650oif.57.1580027658856; Sun, 26 Jan 2020 00:34:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580027658; cv=none; d=google.com; s=arc-20160816; b=aL6jfSY+z2iAB4oGP2sxuM9AxuAJ++d+o7Rr+QPvLBvWxUZ/FFFgu6isW6RurUhqv4 21dOxtVhhcCpkb48cv1CM+abejbXrbOic/oFZEJJXH0OdPGpqaw9WNIs7aQZuVAVaxSx y9rE3GQectNHb5MUyZXmQjMv7CxF0xEM703tucaum4Go9MArEpJ9EjZlu2EDBlRKuJQW 2zosxT2OKxt+HfpZNSCDhzJzgcGcYxLiFni2TW1Y/8A1JsrhICubwNtJ+WOhAtFkmgQ2 F8Bpk4mKNnmHyllC+omsy/rGEGHavEGvS+6pCpEayVJyFTtaowFGUr3+O/A0MOdk1d8n OdPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=A/HVm3170PfNClVZmwRIPi9sbl79x5ttiRZ0PyXbaOs=; b=z1ItqG0p404Cm7hq6IqrbYpOUm1RaQShqj6sIlUYP0e7UDMbEMkR+QeJ+BJcukRWsu 0gcnI467pVqUyK4KiLro1/4UuAk+7HaY7XBgsjd+1/OnwqHOb5NK7Z0Ohrpsq73sqCdH DBawzhERqxfF6RIjIhiYuCruh0+UXl9JKXt+mJbg7BieqrItOEG46use3DfToM5VqItu FzJUlxPRFWgZmh4FZos2tOSBeWjc/Pm40rLEsEdZIKEertGXbHClhpGW8y9i4x9O1rAK nLWIcicKaIuC0XhOqcl5WSzww83D7yIaFb5qN3TPkvkucc8rSZ+Iv/cOxcSYYqdssn9v EFmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HHwGpHp8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a13si3500705otq.201.2020.01.26.00.33.54; Sun, 26 Jan 2020 00:34:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HHwGpHp8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729134AbgAZIbj (ORCPT + 99 others); Sun, 26 Jan 2020 03:31:39 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:35800 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727773AbgAZIbj (ORCPT ); Sun, 26 Jan 2020 03:31:39 -0500 Received: by mail-pg1-f196.google.com with SMTP id l24so3568684pgk.2 for ; Sun, 26 Jan 2020 00:31:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=A/HVm3170PfNClVZmwRIPi9sbl79x5ttiRZ0PyXbaOs=; b=HHwGpHp8EjYpAYINXZLEuharzk0X51UuHHpyTyfFiQjf99Ug+UeaH7b6oMx3WSSJ9n 75b3FsJrP9XMA2TDewW/ppYYDGPukuhvtVUIf+onMq/r1PID3jJEVzjaG5pA8hCjnTkw y8Tq7T424WEJ3+RhbZFT3776kKXwaSkFkb1NMs5TGXikTm1tl/qmdxuwkZGwfDngmTlT BTcs6t0/QyS3Cwk49wDsAk+J4ti3SBb3QwJgUoKEUTjZu0fB1+LnGndpGpKfTvTFiDJV Dsc7hOCi10ikLC0OxuCrdpkcc7nn7yUkK34myAk6LJDsH4uM3LYtdY0+CSKK6IYnEirD G/kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=A/HVm3170PfNClVZmwRIPi9sbl79x5ttiRZ0PyXbaOs=; b=fLfEEeKN2gnYPlS6jK/Kt1nueLJSycXcvJBLmE4aQhBkUmH5LArQT46qa+zfZOnyKA ciH88CbMvzdr+NQc2sdFV9F0W+/dSy3nk4wSNRX60Dpb2wa+oLk9KW6gCYpfOdN3GgsI 8+HAUBjg7YvbYOtepfYXHrrnPuYLNb/RYJlJ/ctQJhiHRBwCxuLhndUTyvw2nybDFpX5 ijhjgOiD6xjMv4gDOB8Sj3R0Ihu3wq3fkrirgruI3EH9SXdgJR9PDfaoZejTmR5yhqOM taxMALP145PzAUJI83BushaeywGmrHDihCXO4s4UNwkGgp7pj8ujlkAsObhAO0pF0Yqe nRgQ== X-Gm-Message-State: APjAAAUExupfOBfdaldVRfNhCBY9TMsKDMnYtyYNEoW7JAWKMmi80tho D1T8+JWqOGtwYMML6msB3dg= X-Received: by 2002:a65:5ccc:: with SMTP id b12mr13255457pgt.124.1580027498692; Sun, 26 Jan 2020 00:31:38 -0800 (PST) Received: from google.com ([123.201.163.10]) by smtp.gmail.com with ESMTPSA id z64sm11988940pfz.23.2020.01.26.00.31.35 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sun, 26 Jan 2020 00:31:38 -0800 (PST) Date: Sun, 26 Jan 2020 14:01:30 +0530 From: Saurav Girepunje To: vireshk@kernel.org, johan@kernel.org, elder@kernel.org, gregkh@linuxfoundation.org, greybus-dev@lists.linaro.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: saurav.girepunje@hotmail.com Subject: [PATCH] staging: greybus: fix fw is NULL but dereferenced. Message-ID: <20200126083130.GA17725@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline User-Agent: Mutt/1.6.2-neo (NetBSD/sparc64) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix the warning reported by cocci check. Changes: In queue_work fw dereference before it actually get assigned. move queue_work before gb_bootrom_set_timeout. As gb_bootrom_get_firmware () return NEXT_REQ_READY_TO_BOOT only when there is no error and offset + size is actually equal to fw->size. So initialized next_request to NEXT_REQ_GET_FIRMWARE for return in other case. Signed-off-by: Saurav Girepunje --- drivers/staging/greybus/bootrom.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/greybus/bootrom.c b/drivers/staging/greybus/bootrom.c index a8efb86..f54514e 100644 --- a/drivers/staging/greybus/bootrom.c +++ b/drivers/staging/greybus/bootrom.c @@ -246,7 +246,7 @@ static int gb_bootrom_get_firmware(struct gb_operation *op) struct gb_bootrom_get_firmware_response *firmware_response; struct device *dev = &op->connection->bundle->dev; unsigned int offset, size; - enum next_request_type next_request; + enum next_request_type next_request = NEXT_REQ_GET_FIRMWARE; int ret = 0; /* Disable timeouts */ @@ -296,13 +296,11 @@ static int gb_bootrom_get_firmware(struct gb_operation *op) unlock: mutex_unlock(&bootrom->mutex); -queue_work: /* Refresh timeout */ if (!ret && (offset + size == fw->size)) next_request = NEXT_REQ_READY_TO_BOOT; - else - next_request = NEXT_REQ_GET_FIRMWARE; +queue_work: gb_bootrom_set_timeout(bootrom, next_request, NEXT_REQ_TIMEOUT_MS); return ret; -- 1.9.1