From patchwork Wed Feb 7 21:17:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 198094 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2510292dyb; Wed, 7 Feb 2024 13:17:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDPtjX4Lh5JTe1rXSNFzA/VQS2EAZvNagqqhH0fIhfIv3MwrOqleGETfPNJfRInh7MYRmh X-Received: by 2002:a17:90b:3146:b0:28f:fa10:937c with SMTP id ip6-20020a17090b314600b0028ffa10937cmr4148306pjb.36.1707340670994; Wed, 07 Feb 2024 13:17:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707340670; cv=pass; d=google.com; s=arc-20160816; b=RloEFpw9zkVMznj2fBkKJFrgDNukE8bpNGMW6LBF00FkCkhbHTa5oL0XfB8mhvTRro SvDX6WCSms9Bq/+eIaASeYrq7Q3TtDtjgjz2+EYdwoEp1Z12h3Eyw6GAlGOY5maRk5Mw Y1Q0lNOFToLdZiiKhZ+NqPCOemM6CK995pzUqgpBPP5xZholC1UlNdzbIEMz039rJlWY ueZnRHhAjfwi/NzAfZa02ce4Dcydrva4ImAHGhfto0PyMJjgxZWeg3fX9XRkQp3931VQ EY7gxXk0U2YdlwfQHLGCFG/Pb/mdnLv1IE3QhfqjEgxdveX01H+Tbo9Dl5H7kk7h1tke 5EgQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=iP3kkGz7gSAbzXRqG5pPEc7tTjDb7YBxeLYLponH8zY=; fh=G0GldaaPDFjU9NAZDDujY1yqOvBt0eTV8VPn3a7N32w=; b=H2PAzkRFcbUnQ39ilbIwDRn7AIjp3dNSUvuka4f2+EKYtVO1+OCtxG6UJPxaSINNZc KGOj7KDvrJv9DGKeGRetHH7fsbU8LFbB87mkKUKnoHby6g4beW9FhGLm8I1uOKeKm3Ai WJ+WqYUgy+N6MF4XLFL16BYTZivQTn5/k1Pr9x9fELRKnH7Mv/mKY4MYs+sRli8qrRD2 5EiDmUv12+o3nu4SUs0ey7mKTpB/EICjlCntmG5XbKh+chF2g6rGU5COb/rtQFKwsLaM 6grP7hl1R10TvOPXFewAjwwC6JqL4ub6dxQFlq66NrgFGl6IfTFlmvVEujZIXAg4WKT5 2DBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GV827iex; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-57062-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57062-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCXqdAz9FzFnzC9Am4EoVNTxYszbNjXtbsjxemgjS/SaLVR0PRVhf8JP35moN+5WzwPTQQh293QjqkJFJ0cVLcMaqp1B8g== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ot4-20020a17090b3b4400b00296a3c5fb15si4396207pjb.34.2024.02.07.13.17.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 13:17:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57062-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GV827iex; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-57062-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57062-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B6680281DED for ; Wed, 7 Feb 2024 21:17:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 14B0D129A9E; Wed, 7 Feb 2024 21:17:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GV827iex" Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 658B4127B4A; Wed, 7 Feb 2024 21:17:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707340635; cv=none; b=NAXzZkJT/z0dSZaFmbr1ul+yZdEfKDokepA3jO/tPG/w4ShOuWRthBVjeoPS3rPAKaunaiDJO3J8uHnTgyva5z4MQWbdL3CnIbJnwMBC9AYPtBz7AI7HLBst9TmHs/2us3nJY8990UjzI0dbY/6dqD3H09JcyOesvFjWNU8OzgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707340635; c=relaxed/simple; bh=NYZpM+IYT/xIIde173sVPPc8ESzfdo3M3EJ+e0bPr+8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hlfTPBLgC/WuGovOYjqP86w1tORQEYBL08a/zyeT9ruXFtHhjZAVDH8a0s1y38b6U2ZN2v8+HtlMV/R/hs9N+SOharG8HIw3dqY9ciCfNiGShzz2j8fawtm2mqdfY96NETeA9X0S4zZz8FKPS4s2Pq1f3yZGlVHDJJXHq50kGls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GV827iex; arc=none smtp.client-ip=209.85.208.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2d0ce22b5f3so7704291fa.1; Wed, 07 Feb 2024 13:17:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707340631; x=1707945431; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=iP3kkGz7gSAbzXRqG5pPEc7tTjDb7YBxeLYLponH8zY=; b=GV827iexO4lr8renPwjEvkD5IMKYRPr6HUCH1Hfq7EBTclWMVpsi/a1g24/kls1PHJ MBNZY7QBZJjMb4mxIEZxfvXUfR/XHizvOqipc80+WRcxIpSIfdP8e2uvS0es8T+7TJJx +7bJgaJEYzwQKLkYTZY814XAqE1CPzuT0XBq13Fihnq2+tRhOreFo3IizjNCfsBBgEcC TTWjS0CQue+4jFeBIQzLpSuCrVh3IzkRtISctOlCRqPD4wFPMgBK9s/Y7V7Or27Lt2HV Vp7xTno1aO9T1BseNSncKu1VgC2E6oSB0R3PULDvFldRBE2u9Wzwz9Rz/eUf+GBSAOOY U29w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707340631; x=1707945431; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iP3kkGz7gSAbzXRqG5pPEc7tTjDb7YBxeLYLponH8zY=; b=DwiME0/tEkcY5KZHQeEtVjMH7UYjLiAQwQE20FnJViZT8nW5DAipWVelpGPZw167V2 MjGq50JOmvbaLz/ZbqyleWUR+lGmDR5Lo0Xz21hWO0TVU/bSxIcmj+qpC2f3aOTKpeNo 0jQLIXeJzqVkHs0zmEib30OsVCx0jyhMMGRAxTVgwrhzOOQS4kds8MIoyfkxWKAaCLd4 xHlNxtOIzx7GmPqjQi4qls1Xba6PEBnEfWb/g9OfZE0lGkopszenzaOvSEmTZ9/EFEvk v+aKawRtgpl62IuMtSEbcOUIk5QxBPn/jnv10+6P97X4riwP4KTVImPcOmSLlLvMLyXR Wq+w== X-Gm-Message-State: AOJu0YwQw57kRnnfg0QeSYdl/Ec1nx744o6rkl3mPxRbuevJD+y4smMS +S0i6aa1KuvvumSVVnkQzk/0X/AvhlKurE/ciT2HzpQfib5ZvW7K X-Received: by 2002:a2e:804b:0:b0:2d0:66cd:8637 with SMTP id p11-20020a2e804b000000b002d066cd8637mr5329506ljg.41.1707340631222; Wed, 07 Feb 2024 13:17:11 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWVOW9H/KoRuIOZqIaCNcQ9teVy/xZScd5YEX1yiC0meAeHMO9a0nseEaPKHBVtotbB0Xeyw0kmUtTURHobEJED8vPDK7MnsYDhfedgGysFIB+aOiMOkSL55E9dPMRhSjNhoFh9BHxqPoNY6ByXDhcDrNuLJHgwL5dIFcDeTv4rGfLih7HpB3JtsrgdEtwT1N5+u5RpuhIjuD3Z Received: from [127.0.1.1] (2a02-8389-41cf-e200-3314-d4ec-5095-daa3.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3314:d4ec:5095:daa3]) by smtp.gmail.com with ESMTPSA id h3-20020a0564020e8300b00560622cd10fsm98362eda.68.2024.02.07.13.17.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 13:17:10 -0800 (PST) From: Javier Carrasco Date: Wed, 07 Feb 2024 22:17:08 +0100 Subject: [PATCH 1/2] hwmon: chipcap2: fix uninitialized variable in cc2_get_reg_val() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240207-chipcap2_init_vars-v1-1-08cafe43e20e@gmail.com> References: <20240207-chipcap2_init_vars-v1-0-08cafe43e20e@gmail.com> In-Reply-To: <20240207-chipcap2_init_vars-v1-0-08cafe43e20e@gmail.com> To: Jean Delvare , Guenter Roeck , Dan Carpenter Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.13-dev-0434a X-Developer-Signature: v=1; a=ed25519-sha256; t=1707340628; l=1189; i=javier.carrasco.cruz@gmail.com; s=20230509; h=from:subject:message-id; bh=NYZpM+IYT/xIIde173sVPPc8ESzfdo3M3EJ+e0bPr+8=; b=hq+dmogC+6WNc0XZnq3PNPzOt9pIgsUJm+gwsRP/m9lKu3QOnW3KGWfDztWs+IJwJqgWG+Q7N rIZjrohiaxkD+kYqaRmcjseSLLW/ZU0T8oDYdgzsyl6QFC5oJRn7iEG X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790276451628861185 X-GMAIL-MSGID: 1790276451628861185 The reg_val variable in cc2_get_reg_val() might be used without a known value if cc2_read_reg() fails. That leads to a useless data conversion because the returned error means the read operation failed and the data is not relevant. That makes its initial value irrelevant as well, so skip the data conversion instead. If no error happens, a value is assigned to reg_val and the data conversion is required. Reported-by: Dan Carpenter Closes: https://lore.kernel.org/linux-hwmon/294e4634-89d4-415e-a723-b208d8770d7c@gmail.com/T/#t Signed-off-by: Javier Carrasco --- drivers/hwmon/chipcap2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/chipcap2.c b/drivers/hwmon/chipcap2.c index a62c507b1042..3b604fc5d8ae 100644 --- a/drivers/hwmon/chipcap2.c +++ b/drivers/hwmon/chipcap2.c @@ -324,7 +324,9 @@ static int cc2_get_reg_val(struct cc2_data *data, u8 reg, long *val) int ret; ret = cc2_read_reg(data, reg, ®_val); - *val = cc2_rh_convert(reg_val); + if (!ret) + *val = cc2_rh_convert(reg_val); + cc2_disable(data); return ret; From patchwork Wed Feb 7 21:17:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 198095 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2510356dyb; Wed, 7 Feb 2024 13:18:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVLg6mCop79Oblh1mJ37KlNLANiTSouksi323V1CNNe62GLJqN7rnJn3QdYDeYPwDmkKr2z6C5OFj98zL9YRUcc0s3wcg== X-Google-Smtp-Source: AGHT+IFz/1Wv0G7Wf9SQ6UqtQLcpaNPk3+jFh0ZUvxrRZ5sHIQaKk22zoT2Kz8IY+/UuZTb4XCOv X-Received: by 2002:a05:6e02:1d9e:b0:363:d847:168b with SMTP id h30-20020a056e021d9e00b00363d847168bmr5944208ila.27.1707340680815; Wed, 07 Feb 2024 13:18:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707340680; cv=pass; d=google.com; s=arc-20160816; b=wUxNvbJ+w3Ut4W7Kpqzd9FC8ijjP6UhGt90kp6vKeJxcShn6HEdHJsp7DH7InGi1j8 HfHOp0zM+CNvBAiFY+s5zq1atDYHtzbTSSUOhvejnYqBtXVXl0alckaGnmTN21i64MAf hStbsqfuFkymB+eld+v5IcXhelqaeBdYpWJ+p6PTEzDBWH4fOY85XfoID+iJ87D1XofB qssU1AjuPEOLR2AgSe63i/YWagsr3/gZclSz1a8FI7augoCAn4P04BxBxx1yxSUS/4Cp bt4Lop8tm8A6/CMgWdUyVskHQDWom0k7rWrkerJaW6pLt0+tnJ+8Rp32ExAvaj/IP2es 7dKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=dgfzTVksahqxWw0KuisYDJC38lg+Vl3GjMkmu7mWaIo=; fh=7ttFMpBr14VF3IcDDtFqBqs9Yu/NwJPxPfZU+eDOr2I=; b=wWWzmeB17J4yQGryiidZIBT5WtzjDNjIcDyXmKXnnSNDaEZvPW+VLou8DWSIARPpLf Y4WrF9HzuHGmLXURnxeAony+KGrmNXViDobHBLa9HuPhBFtaFWWkP/QBqKVmSyPi4BMu wdbgU/9Il4GMeFfEKc5VAM53AkIn5tW99cMGPEm5uLs70vtwvD9WRs6Z3FrXUImvtJ7z lnTLsnulmXVvafP0OsTnN6e3gz3Rz0BYMUK0a/y6vWgKoi4BSNs88sTUBuz/3IyxjPcW 99Z5PCzdGGXQUObG0pjdVXQfKKzOR3w6PUm5G80FRBy/mExsjjTneYa0CS+Jgvd3yuz2 EDyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hoKHhr7n; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-57063-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57063-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCUWfbbmP6bxRTO/FDRIvO9mEXY/s81WDui+Maa01w+b0JoHqzEM3Uge+eIK9f9NUZx0AbgyOOqIgTehkD7AHSDepj8v+Q== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e21-20020a633715000000b005dc1b8a6c7bsi2322983pga.354.2024.02.07.13.18.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 13:18:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57063-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hoKHhr7n; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-57063-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57063-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7BD6628B1F2 for ; Wed, 7 Feb 2024 21:18:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D35F127B6A; Wed, 7 Feb 2024 21:17:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hoKHhr7n" Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F6F112838C; Wed, 7 Feb 2024 21:17:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707340636; cv=none; b=JMkty4ilNBs05Z8klKzAxxhuCGsmr5StDCLKl6kZHoIHe0f4rKSsH4bsvcBxtiqcq4QD2ciW5KLPPNgbLBBWpOGCyBKg55PWmNrP7mVDxDFUyoiKc22dgOwm6AaarWIrl8NLwE570isJL5V8KfMlpuax5FsNIi9U0LZI26qA7XA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707340636; c=relaxed/simple; bh=kR8W6XaSITp6FtKm662SPQ78CZF78Rrgzk4MuYq0O+s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CoynvQoVdDRX+EqTK8wLdHzyob3IEHjgQ1DYtxCrmDlflvE07pbigMlrfiKyZ8+qyGFuJX1TfarCCtVNnPDaaEJkDRM7Uw1j+V9GWX4gJOYgw3xD1XZPKYgTYi1mO13HbCHFEVpAEE5fz6XLOw4tDVU+9OXunstnKkqceyMgfT0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hoKHhr7n; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-560c696ccffso480055a12.1; Wed, 07 Feb 2024 13:17:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707340633; x=1707945433; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=dgfzTVksahqxWw0KuisYDJC38lg+Vl3GjMkmu7mWaIo=; b=hoKHhr7n0Wf76amYpGbMnzjj90asgYO4W5LZWNTdLZWRYW+gfMbdO+kqOJQByR++cr mclUkGpfcm+HXMM5bGQXufYDnfx8uiO+auG/GXrCUwfb0i4inHl7CuGetpsJlIOsRffv 9fcr9sNn3G36eMpbEYZ2pvAq57SL27OdL38e8WMYw63v5+Plct43TK54+NxwFl8itdY7 GW7d6IH3fi9FY/sP5rTFcRJt113zLfkoea/6BJe7zTPFaE/o+DYjqPHadK31Y44ubgjM 6sKOj4hzo+Q2GlsVVMoqlIC4GF5NgrYmkF1QSAjepo/aXkzIdARAwgH26vBfkNBi/O90 b1dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707340633; x=1707945433; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dgfzTVksahqxWw0KuisYDJC38lg+Vl3GjMkmu7mWaIo=; b=u2dx4fFjYgYxzT2u05LIWBJS8ZRqfN2IUBlNWGcdo+zIzSa7zoTT74vNdcnGVXHcxp P9j0d+4/zX4s4iwRseqA7K8jF0hwdGKvnxtdzaYSPQfbMuiXljX0KQrWvD1PSIsOCrGU eofeOGVXO22PslmMvz3XM3vf+HRYDIuEYZBunCInYLVO9A0CdUpHaZ0bqEFgims2CFvG PwBpSFK8sA3cVbRHaLGXVBdMvKmZtW7WbKBLjZKvzEtsnZ5e1iSIvoGjMqoYcla5BKl9 f5cWj9PCs5A4Z6Dai64gMd7dlFoeGCAj0UVpeC6PQ0Q0idWCkM/sY4ug5fJywD8DVPoS hT9Q== X-Forwarded-Encrypted: i=1; AJvYcCX3HezlKXkzI51TdRjcsYvnfkYhukZABygFH5R4sSDynIKEsNyzd0J2FZNKkm0kcb1+9nnePDXVzcCctULbrYlYeVQniwb5ApYK5HvA X-Gm-Message-State: AOJu0Yyan/ifWlRwhyHrk8qLpDUVqjoFXVP+HeuriA+q97oc6eywUFgC Y/zqOqUH5TdLg0rSlxN2cTY91zWh7kOdGIsXo56QOjMX3FQm8W4e X-Received: by 2002:a50:9fc3:0:b0:55f:e744:71fa with SMTP id c61-20020a509fc3000000b0055fe74471famr627388edf.18.1707340632686; Wed, 07 Feb 2024 13:17:12 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXey/cH2FlVTD9OzfSIIRtS3+XVuhMv0EUqqeynNVYUNBqwMvjYo/s0VXIZKN/fUM7svy+/Wc4PCjsp0QN7q4oLjrCogQ797zMfF863k89tE6UXI0saUdUCYGZbYw8AXuT+ITH/wGWzZXAb2P1n+W3ef+0X2DMo1XWT3yZj889t5beWd/FiRUoKs/Y1d3YWKPZRiuLJZtXnruSt Received: from [127.0.1.1] (2a02-8389-41cf-e200-3314-d4ec-5095-daa3.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3314:d4ec:5095:daa3]) by smtp.gmail.com with ESMTPSA id h3-20020a0564020e8300b00560622cd10fsm98362eda.68.2024.02.07.13.17.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 13:17:11 -0800 (PST) From: Javier Carrasco Date: Wed, 07 Feb 2024 22:17:09 +0100 Subject: [PATCH 2/2] hwmon: chipcap2: fix return path in cc2_request_alarm_irqs() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240207-chipcap2_init_vars-v1-2-08cafe43e20e@gmail.com> References: <20240207-chipcap2_init_vars-v1-0-08cafe43e20e@gmail.com> In-Reply-To: <20240207-chipcap2_init_vars-v1-0-08cafe43e20e@gmail.com> To: Jean Delvare , Guenter Roeck , Dan Carpenter Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.13-dev-0434a X-Developer-Signature: v=1; a=ed25519-sha256; t=1707340628; l=2046; i=javier.carrasco.cruz@gmail.com; s=20230509; h=from:subject:message-id; bh=kR8W6XaSITp6FtKm662SPQ78CZF78Rrgzk4MuYq0O+s=; b=J1G74un+07m36ZfbGe9xs4/GVbjkUp9yXyXSWA1BAdd9FiVjUjH8AucF4kEDtDJmEGzyTeP3q CBKGRvsPII0DT4bqhnq0XPWVvZSwYvBcFl98kDFb80361d19ny2YjR9 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790276461632716023 X-GMAIL-MSGID: 1790276461632716023 The return path can be improved by returning upon first failure. The current implementation would try to register the second interrupt even if the first one failed, which is unnecessary. Moreover, if no irqs are available, the return value should be zero (the driver supports the use case with no interrupts). Currently the initial value is unassigned and that may lead to returning an unknown value if stack variables are not automatically set to zero and no irqs were provided. Reported-by: Dan Carpenter Closes: https://lore.kernel.org/linux-hwmon/294e4634-89d4-415e-a723-b208d8770d7c@gmail.com/T/#t Signed-off-by: Javier Carrasco --- drivers/hwmon/chipcap2.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/chipcap2.c b/drivers/hwmon/chipcap2.c index 3b604fc5d8ae..6ccceae21f70 100644 --- a/drivers/hwmon/chipcap2.c +++ b/drivers/hwmon/chipcap2.c @@ -670,7 +670,7 @@ static int cc2_request_ready_irq(struct cc2_data *data, struct device *dev) static int cc2_request_alarm_irqs(struct cc2_data *data, struct device *dev) { - int ret; + int ret = 0; data->irq_low = fwnode_irq_get_byname(dev_fwnode(dev), "low"); if (data->irq_low > 0) { @@ -679,8 +679,10 @@ static int cc2_request_alarm_irqs(struct cc2_data *data, struct device *dev) IRQF_ONESHOT | IRQF_TRIGGER_RISING, dev_name(dev), data); - if (!ret) - data->rh_alarm.low_alarm_visible = true; + if (ret) + return ret; + + data->rh_alarm.low_alarm_visible = true; } data->irq_high = fwnode_irq_get_byname(dev_fwnode(dev), "high"); @@ -690,8 +692,10 @@ static int cc2_request_alarm_irqs(struct cc2_data *data, struct device *dev) IRQF_ONESHOT | IRQF_TRIGGER_RISING, dev_name(dev), data); - if (!ret) - data->rh_alarm.high_alarm_visible = true; + if (ret) + return ret; + + data->rh_alarm.high_alarm_visible = true; } return ret;