RE: [EXT] Re: [PATCH 2/8] qla2xxx: klocwork - Fix potential null pointer dereference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: Bart Van Assche <bvanassche@xxxxxxx>
> Sent: Wednesday, May 31, 2023 6:04 PM
> To: Nilesh Javali <njavali@xxxxxxxxxxx>; martin.petersen@xxxxxxxxxx
> Cc: linux-scsi@xxxxxxxxxxxxxxx; GR-QLogic-Storage-Upstream <GR-QLogic-
> Storage-Upstream@xxxxxxxxxxx>; Bikash Hazarika <bhazarika@xxxxxxxxxxx>;
> Anil Gurumurthy <agurumurthy@xxxxxxxxxxx>; Shreyas Deodhar
> <sdeodhar@xxxxxxxxxxx>
> Subject: Re: [EXT] Re: [PATCH 2/8] qla2xxx: klocwork - Fix potential null pointer
> dereference
> 
> On 5/31/23 04:43, Nilesh Javali wrote:
> > We can prevent the crash and notify the occurrence of this
> > rare case by adding warn_on like,
> >
> > +       WARN_ON_ONCE(!cur_dsd);
> > +       if (cur_dsd) {
> > +               cur_dsd->address = 0;
> > +               cur_dsd->length = 0;
> > +               cur_dsd++;
> > +       }
> >          cmd_pkt->control_flags |= cpu_to_le16(CF_DATA_SEG_DESCR_ENABLE);
> >          return 0;
> >   }
> 
> I think there is a much better solution: drop the new "if (cur_dsd) {"
> test and instead add the following code:
> 
> diff --git a/drivers/scsi/qla2xxx/qla_iocb.c
> b/drivers/scsi/qla2xxx/qla_iocb.c
> index 6acfdcc48b16..a1675f056a5c 100644
> --- a/drivers/scsi/qla2xxx/qla_iocb.c
> +++ b/drivers/scsi/qla2xxx/qla_iocb.c
> @@ -607,7 +607,8 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct
> cmd_type_6 *cmd_pkt,
>   	put_unaligned_le32(COMMAND_TYPE_6, &cmd_pkt->entry_type);
> 
>   	/* No data transfer */
> -	if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
> +	if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE ||
> +	    tot_dsds == 0) {
>   		cmd_pkt->byte_count = cpu_to_le32(0);
>   		return 0;
>   	}
> 
> Is the above change sufficient to suppress the Klocwork warning?

This looks good and does not generate any new klocwork warning.
I will re-send the series with this change included.

Thanks,
Nilesh




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux