* [PATCH v2 1/1] xfs: Fix Smatch warning in xfs_attr_node_get
@ 2020-07-29 4:37 Allison Collins
2020-07-29 19:59 ` Darrick J. Wong
0 siblings, 1 reply; 3+ messages in thread
From: Allison Collins @ 2020-07-29 4:37 UTC (permalink / raw)
To: linux-xfs
Fix warning: variable dereferenced before check 'state' in
xfs_attr_node_get. If xfs_attr_node_hasname fails, it may return a null
state. If state is null, do not release paths or derefrence state
Signed-off-by: Allison Collins <allison.henderson@oracle.com>
---
fs/xfs/libxfs/xfs_attr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index e5ec9ed..38fe0d3 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -1422,7 +1422,7 @@ xfs_attr_node_get(
* If not in a transaction, we have to release all the buffers.
*/
out_release:
- for (i = 0; i < state->path.active; i++) {
+ for (i = 0; i < state && state->path.active; i++) {
xfs_trans_brelse(args->trans, state->path.blk[i].bp);
state->path.blk[i].bp = NULL;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] xfs: Fix Smatch warning in xfs_attr_node_get
2020-07-29 4:37 [PATCH v2 1/1] xfs: Fix Smatch warning in xfs_attr_node_get Allison Collins
@ 2020-07-29 19:59 ` Darrick J. Wong
2020-07-29 20:02 ` Allison Collins
0 siblings, 1 reply; 3+ messages in thread
From: Darrick J. Wong @ 2020-07-29 19:59 UTC (permalink / raw)
To: Allison Collins; +Cc: linux-xfs
On Tue, Jul 28, 2020 at 09:37:47PM -0700, Allison Collins wrote:
> Fix warning: variable dereferenced before check 'state' in
> xfs_attr_node_get. If xfs_attr_node_hasname fails, it may return a null
> state. If state is null, do not release paths or derefrence state
>
> Signed-off-by: Allison Collins <allison.henderson@oracle.com>
Looks ok, though I folded all these into the for-next rebase (and then
forgot to push send on this...)
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> fs/xfs/libxfs/xfs_attr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index e5ec9ed..38fe0d3 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -1422,7 +1422,7 @@ xfs_attr_node_get(
> * If not in a transaction, we have to release all the buffers.
> */
> out_release:
> - for (i = 0; i < state->path.active; i++) {
> + for (i = 0; i < state && state->path.active; i++) {
> xfs_trans_brelse(args->trans, state->path.blk[i].bp);
> state->path.blk[i].bp = NULL;
> }
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] xfs: Fix Smatch warning in xfs_attr_node_get
2020-07-29 19:59 ` Darrick J. Wong
@ 2020-07-29 20:02 ` Allison Collins
0 siblings, 0 replies; 3+ messages in thread
From: Allison Collins @ 2020-07-29 20:02 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: linux-xfs
On 7/29/20 12:59 PM, Darrick J. Wong wrote:
> On Tue, Jul 28, 2020 at 09:37:47PM -0700, Allison Collins wrote:
>> Fix warning: variable dereferenced before check 'state' in
>> xfs_attr_node_get. If xfs_attr_node_hasname fails, it may return a null
>> state. If state is null, do not release paths or derefrence state
>>
>> Signed-off-by: Allison Collins <allison.henderson@oracle.com>
>
> Looks ok, though I folded all these into the for-next rebase (and then
> forgot to push send on this...)
>
No worries, thank you!
Allison
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
>
> --D
>
>> ---
>> fs/xfs/libxfs/xfs_attr.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
>> index e5ec9ed..38fe0d3 100644
>> --- a/fs/xfs/libxfs/xfs_attr.c
>> +++ b/fs/xfs/libxfs/xfs_attr.c
>> @@ -1422,7 +1422,7 @@ xfs_attr_node_get(
>> * If not in a transaction, we have to release all the buffers.
>> */
>> out_release:
>> - for (i = 0; i < state->path.active; i++) {
>> + for (i = 0; i < state && state->path.active; i++) {
>> xfs_trans_brelse(args->trans, state->path.blk[i].bp);
>> state->path.blk[i].bp = NULL;
>> }
>> --
>> 2.7.4
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-07-29 20:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-29 4:37 [PATCH v2 1/1] xfs: Fix Smatch warning in xfs_attr_node_get Allison Collins
2020-07-29 19:59 ` Darrick J. Wong
2020-07-29 20:02 ` Allison Collins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).