From: Mike Christie <michael.christie@oracle.com>
To: Daniil Tatianin <d-tatianin@yandex-team.ru>,
"James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
Lee Duncan <lduncan@suse.com>,
Nilesh Javali <njavali@marvell.com>, Wu Bo <wubo40@huawei.com>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
lvc-project@linuxtesting.org, yc-core@yandex-team.ru,
Varun Prakash <varun@chelsio.com>
Subject: Re: [PATCH v2] scsi/cxgbi/libcxgbi: make sure sg is present before calling sg_next()
Date: Tue, 15 Nov 2022 10:59:45 -0600 [thread overview]
Message-ID: <9eed00ba-42b7-081e-cfb1-e61a413ccb3a@oracle.com> (raw)
In-Reply-To: <84a02b26-392e-994d-bd1f-ecc28231fbfc@yandex-team.ru>
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@yandex-team.ru>
>>> ---
>>> 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.
next prev parent reply other threads:[~2022-11-15 17:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20221114150923.3544796-1-d-tatianin@yandex-team.ru>
2022-11-14 22:23 ` Mike Christie
[not found] ` <84a02b26-392e-994d-bd1f-ecc28231fbfc@yandex-team.ru>
2022-11-15 16:59 ` Mike Christie [this message]
[not found] ` <20075199-1e6c-28ad-1440-4dc61985d8f4@yandex-team.ru>
2022-11-17 13:30 ` Varun Prakash
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9eed00ba-42b7-081e-cfb1-e61a413ccb3a@oracle.com \
--to=michael.christie@oracle.com \
--cc=d-tatianin@yandex-team.ru \
--cc=jejb@linux.ibm.com \
--cc=lduncan@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=martin.petersen@oracle.com \
--cc=njavali@marvell.com \
--cc=varun@chelsio.com \
--cc=wubo40@huawei.com \
--cc=yc-core@yandex-team.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®