Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2491171lqp; Sun, 24 Mar 2024 23:21:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVesn1mTw6vHD9bm5GMu9/DsB3VEZIdhXZ5VQN7zn5Z4oC9bMYngZfoBCGIYKHqrRZe9+0l3/dKaTIGyW4W1ggWWDyXqNJd6jvpTdBpTw== X-Google-Smtp-Source: AGHT+IEyU93diVhs8Uz/Yzw9Jv3gnpu/0JFtDDy9sbX43iocxPkGwfnWn9zGoSrej/TyNFthfjgQ X-Received: by 2002:a17:902:ec83:b0:1e0:e70:4264 with SMTP id x3-20020a170902ec8300b001e00e704264mr6787078plg.33.1711347715471; Sun, 24 Mar 2024 23:21:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711347715; cv=pass; d=google.com; s=arc-20160816; b=epnAgQeGOezVuUUdNupdQ0a7erGDJH+jdq92CFHPsbfBgf/K4RxdYWIZCb9ZZ2R3aw Q0nVbFQ7zOTg5tRCbCgeo8bCwQS3ws5kgtDyPDm6vC4of4waJgD8hm40VI1Hyp/ZjCEo OdgSRvD3S8qk2oZtNHLppDwbGXCnuC48+yEN9f5S9Jj5+b63V06AIL8JMK9HwnKvr6+c 2TY6rozWwvNPjLLdg/EmJ2jm3ypibTvgbtrNGwiNvySjm/gtdMZWEtByWug673BGQINe KALxfeDXImCfqYcuQx9p9kg6G1/ykNeDev7mmTyrhy7uC/7dvtRY+x/kJx7bUFmOYPp8 yAGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=vvh5M8HZSEr2NhXe33GVzpZucScDCx8ryNEOC0UqI30=; fh=J/I4lfae/B8A2pH+Dy1lGTB6cyYo+fIywgWCvthylZc=; b=VRxg4II00XAe7F/Ue5Hw+nKazn+qFTfFpjTZ3AoY9hIAabaTt4wQ1PQd+5si/FjB3a 0grhy07JDwZt62gvIf12VOg25tHEUrxvsjHsOWH7h47VCVH8AWlvoe7JcJMV8pd/7EUf 8ajgyyle8dSPeiKmt4xx9JSJOZJh7GBPxD6SgGkSU77Bj17zV8E7lzZ3MSuHufh5qDRR Z7PcrcS2uHZ993KF+YzUJFrGQ8ZR1igsNZEwwt1yjN62K2aul+lgH/cSZRF5XWVU995X PTLlO6pMbalB6uAKCsX27P56p3wweU9rJOcj6XOA1CHCccCV6ClrC7Q9QX1CMKnYHWOb Yx0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H8KYuwbv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114630-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114630-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k12-20020a170902d58c00b001e0b03778a1si3257704plh.73.2024.03.24.23.21.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 23:21:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-114630-linux.lists.archive=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=@kernel.org header.s=k20201202 header.b=H8KYuwbv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114630-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114630-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 2CCAA291E66 for ; Mon, 25 Mar 2024 06:21:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 862352A658B; Sun, 24 Mar 2024 23:56:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H8KYuwbv" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62E1A23318D; Sun, 24 Mar 2024 23:18:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322286; cv=none; b=uynsVnTX3e+A2tVzW3INgYsMzskZrepLHo9ePDJohrNi5nZU8aHdLEz7fB7b+Kw6V5JQ8yBN2bzCBvyrB97GlDGQr4O94GClFgD6tCj9YgUT+TUMI7cg4pm5U55FnuxFb/xs1uEevwtPl6AUQvSUUkW/U7xvKBpcGDg0rlUGEDQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322286; c=relaxed/simple; bh=u09IWd1qZVsAZyxzHseF9kFtpoNg9X/fMsPqkG48VTg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JOjqYXjTqlGUI1BFZaRZzHUUF2s3wgeYXbVIs2/iMvode3Kskv9tbDwRnS+M1m+SbhN296wb+z9V7uYiu7PvrMyqe/zm066aI8bD54P2/Yk+5w0r4uNJhDh8gjPvffbZFGPh5Z848K/kyz0g3a99QQ6ix/ZBggBAlUoyQhThXoc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H8KYuwbv; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8211AC43601; Sun, 24 Mar 2024 23:18:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322285; bh=u09IWd1qZVsAZyxzHseF9kFtpoNg9X/fMsPqkG48VTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H8KYuwbvgpuHSw+T0Se1OycSboGJ167UDEdbsEDhhMCnl0aR4lF1PgQxV9kznrhWt QykLBycIUZcFR5ypkNUTEANcXrhEXq8nAmqk1ij/67mqblRR/ag/uNDeCAgTlA8aeH QCsCYCBI6p3ncsrDCw3pji+qJgKSv2mickHRjkZzYkL5KmMUqhINR6sf1bnC9mQp79 2azQSwL9bxxPfemS9GGQmUGOOBDBWr83zUbkxPbFwSyj+gV+YA6p/yT2043T3ajzax 0Plpcx394AKzvUS6mNJQZkqzqDkC6jS9MmiGHgucOSMEy8YGkCqcoHW+C+nbcUIpY7 Y6chACriDD8fA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Arnd Bergmann , Kees Cook , "Martin K . Petersen" , Sasha Levin Subject: [PATCH 6.1 368/451] scsi: bfa: Fix function pointer type mismatch for hcb_qe->cbfn Date: Sun, 24 Mar 2024 19:10:44 -0400 Message-ID: <20240324231207.1351418-369-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Arnd Bergmann [ Upstream commit b69600231f751304db914c63b937f7098ed2895c ] Some callback functions used here take a boolean argument, others take a status argument. This breaks KCFI type checking, so clang now warns about the function pointer cast: drivers/scsi/bfa/bfad_bsg.c:2138:29: error: cast from 'void (*)(void *, enum bfa_status)' to 'bfa_cb_cbfn_t' (aka 'void (*)(void *, enum bfa_boolean)') converts to incompatible function type [-Werror,-Wcast-function-type-strict] Assuming the code is actually correct here and the callers always match the argument types of the callee, rework this to replace the explicit cast with a union of the two pointer types. This does not change the behavior of the code, so if something is actually broken here, a larger rework may be necessary. Fixes: 37ea0558b87a ("[SCSI] bfa: Added support to collect and reset fcport stats") Fixes: 3ec4f2c8bff2 ("[SCSI] bfa: Added support to configure QOS and collect stats.") Reviewed-by: Kees Cook Signed-off-by: Arnd Bergmann Link: https://lore.kernel.org/r/20240222124433.2046570-1-arnd@kernel.org Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/bfa/bfa.h | 9 ++++++++- drivers/scsi/bfa/bfa_core.c | 4 +--- drivers/scsi/bfa/bfa_ioc.h | 8 ++++++-- drivers/scsi/bfa/bfad_bsg.c | 11 ++++------- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/bfa/bfa.h b/drivers/scsi/bfa/bfa.h index 7bd2ba1ad4d11..f30fe324e6ecc 100644 --- a/drivers/scsi/bfa/bfa.h +++ b/drivers/scsi/bfa/bfa.h @@ -20,7 +20,6 @@ struct bfa_s; typedef void (*bfa_isr_func_t) (struct bfa_s *bfa, struct bfi_msg_s *m); -typedef void (*bfa_cb_cbfn_status_t) (void *cbarg, bfa_status_t status); /* * Interrupt message handlers @@ -437,4 +436,12 @@ struct bfa_cb_pending_q_s { (__qe)->data = (__data); \ } while (0) +#define bfa_pending_q_init_status(__qe, __cbfn, __cbarg, __data) do { \ + bfa_q_qe_init(&((__qe)->hcb_qe.qe)); \ + (__qe)->hcb_qe.cbfn_status = (__cbfn); \ + (__qe)->hcb_qe.cbarg = (__cbarg); \ + (__qe)->hcb_qe.pre_rmv = BFA_TRUE; \ + (__qe)->data = (__data); \ +} while (0) + #endif /* __BFA_H__ */ diff --git a/drivers/scsi/bfa/bfa_core.c b/drivers/scsi/bfa/bfa_core.c index 6846ca8f7313c..3438d0b8ba062 100644 --- a/drivers/scsi/bfa/bfa_core.c +++ b/drivers/scsi/bfa/bfa_core.c @@ -1907,15 +1907,13 @@ bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q) struct list_head *qe; struct list_head *qen; struct bfa_cb_qe_s *hcb_qe; - bfa_cb_cbfn_status_t cbfn; list_for_each_safe(qe, qen, comp_q) { hcb_qe = (struct bfa_cb_qe_s *) qe; if (hcb_qe->pre_rmv) { /* qe is invalid after return, dequeue before cbfn() */ list_del(qe); - cbfn = (bfa_cb_cbfn_status_t)(hcb_qe->cbfn); - cbfn(hcb_qe->cbarg, hcb_qe->fw_status); + hcb_qe->cbfn_status(hcb_qe->cbarg, hcb_qe->fw_status); } else hcb_qe->cbfn(hcb_qe->cbarg, BFA_TRUE); } diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h index 933a1c3890ff5..5e568d6d7b261 100644 --- a/drivers/scsi/bfa/bfa_ioc.h +++ b/drivers/scsi/bfa/bfa_ioc.h @@ -361,14 +361,18 @@ struct bfa_reqq_wait_s { void *cbarg; }; -typedef void (*bfa_cb_cbfn_t) (void *cbarg, bfa_boolean_t complete); +typedef void (*bfa_cb_cbfn_t) (void *cbarg, bfa_boolean_t complete); +typedef void (*bfa_cb_cbfn_status_t) (void *cbarg, bfa_status_t status); /* * Generic BFA callback element. */ struct bfa_cb_qe_s { struct list_head qe; - bfa_cb_cbfn_t cbfn; + union { + bfa_cb_cbfn_status_t cbfn_status; + bfa_cb_cbfn_t cbfn; + }; bfa_boolean_t once; bfa_boolean_t pre_rmv; /* set for stack based qe(s) */ bfa_status_t fw_status; /* to access fw status in comp proc */ diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c index be8dfbe13e904..524e4e6979c9f 100644 --- a/drivers/scsi/bfa/bfad_bsg.c +++ b/drivers/scsi/bfa/bfad_bsg.c @@ -2135,8 +2135,7 @@ bfad_iocmd_fcport_get_stats(struct bfad_s *bfad, void *cmd) struct bfa_cb_pending_q_s cb_qe; init_completion(&fcomp.comp); - bfa_pending_q_init(&cb_qe, (bfa_cb_cbfn_t)bfad_hcb_comp, - &fcomp, &iocmd->stats); + bfa_pending_q_init_status(&cb_qe, bfad_hcb_comp, &fcomp, &iocmd->stats); spin_lock_irqsave(&bfad->bfad_lock, flags); iocmd->status = bfa_fcport_get_stats(&bfad->bfa, &cb_qe); spin_unlock_irqrestore(&bfad->bfad_lock, flags); @@ -2159,7 +2158,7 @@ bfad_iocmd_fcport_reset_stats(struct bfad_s *bfad, void *cmd) struct bfa_cb_pending_q_s cb_qe; init_completion(&fcomp.comp); - bfa_pending_q_init(&cb_qe, (bfa_cb_cbfn_t)bfad_hcb_comp, &fcomp, NULL); + bfa_pending_q_init_status(&cb_qe, bfad_hcb_comp, &fcomp, NULL); spin_lock_irqsave(&bfad->bfad_lock, flags); iocmd->status = bfa_fcport_clear_stats(&bfad->bfa, &cb_qe); @@ -2443,8 +2442,7 @@ bfad_iocmd_qos_get_stats(struct bfad_s *bfad, void *cmd) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(&bfad->bfa); init_completion(&fcomp.comp); - bfa_pending_q_init(&cb_qe, (bfa_cb_cbfn_t)bfad_hcb_comp, - &fcomp, &iocmd->stats); + bfa_pending_q_init_status(&cb_qe, bfad_hcb_comp, &fcomp, &iocmd->stats); spin_lock_irqsave(&bfad->bfad_lock, flags); WARN_ON(!bfa_ioc_get_fcmode(&bfad->bfa.ioc)); @@ -2474,8 +2472,7 @@ bfad_iocmd_qos_reset_stats(struct bfad_s *bfad, void *cmd) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(&bfad->bfa); init_completion(&fcomp.comp); - bfa_pending_q_init(&cb_qe, (bfa_cb_cbfn_t)bfad_hcb_comp, - &fcomp, NULL); + bfa_pending_q_init_status(&cb_qe, bfad_hcb_comp, &fcomp, NULL); spin_lock_irqsave(&bfad->bfad_lock, flags); WARN_ON(!bfa_ioc_get_fcmode(&bfad->bfa.ioc)); -- 2.43.0