Re: [PATCH v2] scsi/cxgbi/libcxgbi: make sure sg is present before calling sg_next()

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

 



Cc'ing the cxgbi/t maintainer, Varun.

On 11/15/22 2:17 AM, Daniil Tatianin wrote:
> On 11/15/22 1:23 AM, Mike Christie wrote:
>> On 11/14/22 9:09 AM, Daniil Tatianin wrote:
>>> sg_next() dereferences the passed sg, therefore we have to verify that
>>> it's present before calling it.
>>>
>>> Found by Linux Verification Center (linuxtesting.org) with the SVACE
>>> static analysis tool.
>>>
>>> Signed-off-by: Daniil Tatianin <d-tatianin@xxxxxxxxxxxxxx>
>>> ---
>>>   drivers/scsi/cxgbi/libcxgbi.c | 3 +--
>>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
>>> index af281e271f88..2ff9810f42a9 100644
>>> --- a/drivers/scsi/cxgbi/libcxgbi.c
>>> +++ b/drivers/scsi/cxgbi/libcxgbi.c
>>> @@ -1196,8 +1196,7 @@ void cxgbi_ddp_set_one_ppod(struct cxgbi_pagepod *ppod,
>>>         if (offset == len) {
>>>           offset = 0;
>>> -        sg = sg_next(sg);
>>> -        if (sg) {
>>> +        if (sg && (sg = sg_next(sg))) {
>>>               addr = sg_dma_address(sg);
>>>               len = sg_dma_len(sg);
>>>           }
>>
>> Is cxgbit_set_one_ppod the same function but it already has the extra
>> sg check?
> 
> Good catch! Certainly looks that way, albeit with messier indentation.
> 
>> Should it be a libcxgb function in libcxgb_ppm.c?
> 
> That makes sense to me. Should I just move both there?

I think you can move one function with a fix to libcxgb and kill the second one.
Name the new function to cxgb_ddp_set_one_ppod then have cxgbi and cxgbt use it.






[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