Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: qat - fix warning on adf_pfvf_pf_proto.c

Building the QAT driver with -Wmaybe-uninitialized triggers warnings in
qat_common/adf_pfvf_pf_proto.c. Specifically, the variables blk_type,
blk_byte, and byte_max may be used uninitialized in handle_blkmsg_req():

make M=drivers/crypto/intel/qat W=1 C=2 "KCFLAGS=-Werror" \
KBUILD_CFLAGS_KERNEL=-Wmaybe-uninitialized \
CFLAGS_MODULE=-Wmaybe-uninitialized

...
warning: ‘byte_max’ may be used uninitialized [-Wmaybe-uninitialized]
warning: ‘blk_type’ may be used uninitialized [-Wmaybe-uninitialized]
warning: ‘blk_byte’ may be used uninitialized [-Wmaybe-uninitialized]

Although the caller of handle_blkmsg_req() always provides a req.type
that is handled by the switch, the compiler cannot guarantee this.

Add a default case to the switch statement to handle an invalid req.type.

Fixes: 673184a2a58f ("crypto: qat - introduce support for PFVF block messages")
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Ahsan Atta <ahsan.atta@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Giovanni Cabiddu and committed by
Herbert Xu
994689b8 90ca8d35

+10
+10
drivers/crypto/intel/qat/qat_common/adf_pfvf_pf_proto.c
··· 148 148 blk_byte = FIELD_GET(ADF_VF2PF_SMALL_BLOCK_BYTE_MASK, req.data); 149 149 byte_max = ADF_VF2PF_SMALL_BLOCK_BYTE_MAX; 150 150 break; 151 + default: 152 + dev_err(&GET_DEV(vf_info->accel_dev), 153 + "Invalid BlockMsg type 0x%.4x received from VF%u\n", 154 + req.type, vf_info->vf_nr); 155 + resp.type = ADF_PF2VF_MSGTYPE_BLKMSG_RESP; 156 + resp.data = FIELD_PREP(ADF_PF2VF_BLKMSG_RESP_TYPE_MASK, 157 + ADF_PF2VF_BLKMSG_RESP_TYPE_ERROR) | 158 + FIELD_PREP(ADF_PF2VF_BLKMSG_RESP_DATA_MASK, 159 + ADF_PF2VF_UNSPECIFIED_ERROR); 160 + return resp; 151 161 } 152 162 153 163 /* Is this a request for CRC or data? */