From nobody Sun Dec 22 02:59:42 2024 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 8E6571EC4C2 for ; Sat, 21 Dec 2024 09:20:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734772831; cv=none; b=ozwBT/VYWiP9Q9OnF0ENZbUky+BwHaCbD6UfDT+5M4iQ+Aa68C+yg0fT6xzkXe9z2zKA8nRIlS+dBQf4YmbSvtkBm4ew5en4AGuhhaWdIawLVG7YPG5ZzgJBXbJ+0Zh2VYIeF9EH4URR33nZw077ezz4Zdcz8MQ8uc/yPY4cXEI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734772831; c=relaxed/simple; bh=xFMyGeeW+BTPfa09a1GSIMGggfdwZuzj+keky3xMZRM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=dRcshLfIDfIvYyTnqjXUR40D67V9uSbMxv83wSj0GVmmFp4ZQaF9lttLsRbLYNbOO+8eVLrddYaE7l/l1AheqZG+Z+UojijpmZOxIBDghWGO0+kNXBDa0lMb7YawSuOppZg30QPG/udjtaWxc/uCrLMi0eh0Z8TRW02khvbvnA0= 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=UJ4P0+5j; arc=none smtp.client-ip=209.85.216.54 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UJ4P0+5j" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2ef7733a1dcso425614a91.3 for ; Sat, 21 Dec 2024 01:20:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734772830; x=1735377630; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZhwcrQsJQmOo2XPFjcrVZyYTE2H2xXLHXnuSNOc9Lw8=; b=UJ4P0+5jU3hnWjKPppvMe2xI/wGlAR/Ge6929zWXjGuLvl6Sl4J4pJCbrkzvbD9tTu s4vT+avcAVzwzcUHT77gLR9j1LneB6B75AuMTiTHCDBKvqP0GVC7Hsgi6TjucBq7txkr yuI9U2G6J9Pakp8dk6wBYMaf3PbCkxC104ZL2wz5O617dquf8TQ6cOXIUTtl7XU70DCu C/+COd+bzfujsEtRujPwOXrvpmpnqFTwOM+7GLxz2RyNT7/kMWXzAnmpU7zaa9iO2iCd SqGCocR1qdB6AXRREcuh/xEweAZMcf5LjfGtbVH8egHurKcjUvFiMMcG6Wzdge+iskYN hD/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734772830; x=1735377630; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZhwcrQsJQmOo2XPFjcrVZyYTE2H2xXLHXnuSNOc9Lw8=; b=IemgWKX6I4sFg7oTrytJ9kHlDyNPI3N8ZUdPb6rwR/9RJR4Uxua3eysjFwzJ8rbvgM EqD6EMz8elT/wXN9XkMBbzQtU+/ma6qK4ZLV2HaJqDmfrpjjoixz4jWiHldjuvG+0Tgk wT2ZHhRXW3AYe0118YO0Tl+oqGzjbf+BVIbQcA/eQbYaD1tWUiyKmONxNoFYEPiWrtyY TLK7l9PZG9yJyP5KWQP0knl4/yX8p1cRjNZDpHIJrIfghcTfLhdykQZG2wjKtj91MKwt mkbJpAAuK+QB/SsJba3Ysp2Cf2LTLm8sja+QcqSJwOa0Xf63hPIg1nnsFRrtMsD+brEI h1+g== X-Forwarded-Encrypted: i=1; AJvYcCXl3B87oPB38cRGa5RwNXzAAi+4kinG7WnVqlTnI6q4xPsMDbPQuG4oUr+LR4XGKzf4aK09prmQACStUt4=@vger.kernel.org X-Gm-Message-State: AOJu0YxOn+m2bx87APihniKwNau5COhzELGu9QfCaygTx6nmLmxmU/66 BmyJEynYiwxIfnyRGtAdRHYN3jvOw1dPobLS64pyv9Cr64D8QKsY X-Gm-Gg: ASbGnculsq4MnHqQ85f3GBVzuKOof9YG9a5IMHINzy9Y3AkJia4fmHOVqnRl752jNlH tDIlcmzpaAP4TgpCeWAPJxlJUYl3hBQmOg+um7XQEryezSDzwzKiaygUBt6y6uwFQZAVN2takBE LnTjACoYAiPNHeS+nYcktCa9KE1TfeMUaon9wqZeIQJqiGskTynIzdEarFjyF9BVPI9SgjBttY+ Lq52g36BHxkZSQ/HHgwa4+6aBg/xHjVACZFk9d4HssJW+62oKwKOeU= X-Google-Smtp-Source: AGHT+IGZuWNEUdTLP2KFf9V3FZ/v2zB12av3VOzf3qrEgXToHRlKoMBvMR3SO31Y2oBIM33pNUJOEw== X-Received: by 2002:a17:90b:2d4f:b0:2ee:d397:1fef with SMTP id 98e67ed59e1d1-2f452eeb60amr3401132a91.6.1734772829736; Sat, 21 Dec 2024 01:20:29 -0800 (PST) Received: from ice.. ([171.76.86.134]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f2ed0d8bb2sm6550949a91.0.2024.12.21.01.20.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 01:20:29 -0800 (PST) From: Nihar Chaithanya To: dpenkler@gmail.com, gregkh@linuxfoundation.org, dan.carpenter@linaro.org, roheetchavan@gmail.com, niharchaithanya@gmail.com, arnd@arndb.de, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Cc: skhan@linuxfoundation.org Subject: [PATCH v2] staging: gpib: cb7210: Add error handling Date: Sat, 21 Dec 2024 14:41:25 +0530 Message-Id: <20241221091121.35476-1-niharchaithanya@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The if condition in cb7210_init_module() would always fail as the value of err is constantly 0. The function cb_pcmcia_init_module() can be refactored into a single line, and can be replaced entirely with pcmcia_register_driver(). Replace redundant cb_pcmcia_init_module() with pcmcia_register_driver() which returns appropriate error code if it fails. Handle the error if it fails and print the debug message. This issue was reported by Coverity Scan. Report: CID 1635894: (#1 of 1): 'Constant' variable guards dead code (DEADCODE) dead_error_line: Execution cannot reach this statement: return -1;. Signed-off-by: Nihar Chaithanya --- v1 --> v2: Replaced the redundant cb_pcmcia_init_module() with pcmcia_register_driver(). drivers/staging/gpib/cb7210/cb7210.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/staging/gpib/cb7210/cb7210.c b/drivers/staging/gpib/cb= 7210/cb7210.c index 63df7f3eb3f3..abd6632d8448 100644 --- a/drivers/staging/gpib/cb7210/cb7210.c +++ b/drivers/staging/gpib/cb7210/cb7210.c @@ -1351,12 +1351,6 @@ static struct pcmcia_driver cb_gpib_cs_driver =3D { .resume =3D cb_gpib_resume, }; =20 -int cb_pcmcia_init_module(void) -{ - pcmcia_register_driver(&cb_gpib_cs_driver); - return 0; -} - void cb_pcmcia_cleanup_module(void) { DEBUG(0, "cb_gpib_cs: unloading\n"); @@ -1526,11 +1520,12 @@ static int __init cb7210_init_module(void) gpib_register_driver(&cb_pcmcia_interface, THIS_MODULE); gpib_register_driver(&cb_pcmcia_accel_interface, THIS_MODULE); gpib_register_driver(&cb_pcmcia_unaccel_interface, THIS_MODULE); - err +=3D cb_pcmcia_init_module(); + err =3D pcmcia_register_driver(&cb_gpib_cs_driver); #endif - if (err) + if (err) { + pr_err("cb7210: registering PCMCIA driver with the bus core failed\n"); return -1; - + } return 0; } =20 --=20 2.34.1